本文整理了Java中org.apache.poi.openxml4j.opc.ZipPackage.<init>()
方法的一些代码示例,展示了ZipPackage.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipPackage.<init>()
方法的具体详情如下:
包路径:org.apache.poi.openxml4j.opc.ZipPackage
类名称:ZipPackage
方法名:<init>
[英]Constructor. Creates a new, empty ZipPackage.
[中]建造师。创建一个新的空ZipPackage。
代码示例来源:origin: org.apache.poi/poi-ooxml
public static OPCPackage create(OutputStream output) {
OPCPackage pkg = new ZipPackage();
pkg.originalPackagePath = null;
pkg.output = output;
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Creates a new package.
*
* @param file
* Path of the document.
* @return A newly created PackageBase ready to use.
*/
public static OPCPackage create(File file) {
if (file == null || (file.exists() && file.isDirectory())) {
throw new IllegalArgumentException("file");
}
if (file.exists()) {
throw new InvalidOperationException(
"This package (or file) already exists : use the open() method or delete the file.");
}
// Creates a new package
OPCPackage pkg = new ZipPackage();
pkg.originalPackagePath = file.getAbsolutePath();
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
OPCPackage pack = new ZipPackage(file, access);
try {
if (pack.partList == null && access != PackageAccess.WRITE) {
代码示例来源:origin: org.apache.poi/poi-ooxml
OPCPackage pack = new ZipPackage(path, access); // NOSONAR
boolean success = false;
if (pack.partList == null && access != PackageAccess.WRITE) {
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Open an user provided {@link ZipEntrySource} with read-only permission.
* This method can be used to stream data into POI.
* Opposed to other open variants, the data is read as-is, e.g. there aren't
* any zip-bomb protection put in place.
*
* @param zipEntry the custom source
* @return A Package object
* @throws InvalidFormatException if a parsing error occur.
*/
public static OPCPackage open(ZipEntrySource zipEntry)
throws InvalidFormatException {
OPCPackage pack = new ZipPackage(zipEntry, PackageAccess.READ);
try {
if (pack.partList == null) {
pack.getParts();
}
// pack.originalPackagePath = file.getAbsolutePath();
return pack;
} catch (InvalidFormatException | RuntimeException e) {
IOUtils.closeQuietly(pack);
throw e;
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Open a package.
*
* Note - uses quite a bit more memory than {@link #open(String)}, which
* doesn't need to hold the whole zip file in memory, and can take advantage
* of native methods
*
* @param in
* The InputStream to read the package from
* @return A PackageBase object
*
* @throws InvalidFormatException
*/
public static OPCPackage open(InputStream in) throws InvalidFormatException,
IOException {
OPCPackage pack = new ZipPackage(in, PackageAccess.READ_WRITE);
try {
if (pack.partList == null) {
pack.getParts();
}
} catch (InvalidFormatException | RuntimeException e) {
IOUtils.closeQuietly(pack);
throw e;
}
return pack;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* @deprecated use {@link OPCPackage#create(OutputStream)}
*/
@Deprecated
public static Package create(OutputStream output) {
Package pkg = null;
pkg = new ZipPackage();
pkg.originalPackagePath = null;
pkg.output = output;
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* @deprecated use {@link OPCPackage#open(InputStream)}
*/
@Deprecated
public static Package open(InputStream in) throws InvalidFormatException,
IOException {
Package pack = new ZipPackage(in, PackageAccess.READ);
if (pack.partList == null) {
pack.getParts();
}
return pack;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
public static OPCPackage create(OutputStream output) {
OPCPackage pkg = null;
pkg = new ZipPackage();
pkg.originalPackagePath = null;
pkg.output = output;
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
public static OPCPackage create(OutputStream output) {
OPCPackage pkg = new ZipPackage();
pkg.originalPackagePath = null;
pkg.output = output;
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* @deprecated use {@link OPCPackage#open(String,PackageAccess)}
*/
@Deprecated
public static Package open(String path, PackageAccess access)
throws InvalidFormatException {
if (path == null || "".equals(path.trim())
|| (new File(path).exists() && new File(path).isDirectory()))
throw new IllegalArgumentException("path");
Package pack = new ZipPackage(path, access);
if (pack.partList == null && access != PackageAccess.WRITE) {
pack.getParts();
}
pack.originalPackagePath = new File(path).getAbsolutePath();
return pack;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Open a package.
*
* Note - uses quite a bit more memory than {@link #open(String)}, which
* doesn't need to hold the whole zip file in memory, and can take advantage
* of native methods
*
* @param in
* The InputStream to read the package from
* @return A PackageBase object
*/
public static OPCPackage open(InputStream in) throws InvalidFormatException,
IOException {
OPCPackage pack = new ZipPackage(in, PackageAccess.READ_WRITE);
if (pack.partList == null) {
pack.getParts();
}
return pack;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Open a package.
*
* @param path
* The document path.
* @param access
* PackageBase access.
* @return A PackageBase object, else <b>null</b>.
* @throws InvalidFormatException
* If the specified file doesn't exist, and a parsing error
* occur.
*/
public static OPCPackage open(String path, PackageAccess access)
throws InvalidFormatException {
if (path == null || "".equals(path.trim())
|| (new File(path).exists() && new File(path).isDirectory()))
throw new IllegalArgumentException("path");
OPCPackage pack = new ZipPackage(path, access);
if (pack.partList == null && access != PackageAccess.WRITE) {
pack.getParts();
}
pack.originalPackagePath = new File(path).getAbsolutePath();
return pack;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* @deprecated use {@link OPCPackage#create(File)}
*/
@Deprecated
public static Package create(File file) {
if (file == null || (file.exists() && file.isDirectory()))
throw new IllegalArgumentException("file");
if (file.exists()) {
throw new InvalidOperationException(
"This package (or file) already exists : use the open() method or delete the file.");
}
// Creates a new package
Package pkg = null;
pkg = new ZipPackage();
pkg.originalPackagePath = file.getAbsolutePath();
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Creates a new package.
*
* @param file
* Path of the document.
* @return A newly created PackageBase ready to use.
*/
public static OPCPackage create(File file) {
if (file == null || (file.exists() && file.isDirectory())) {
throw new IllegalArgumentException("file");
}
if (file.exists()) {
throw new InvalidOperationException(
"This package (or file) already exists : use the open() method or delete the file.");
}
// Creates a new package
OPCPackage pkg = new ZipPackage();
pkg.originalPackagePath = file.getAbsolutePath();
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Creates a new package.
*
* @param file
* Path of the document.
* @return A newly created PackageBase ready to use.
*/
public static OPCPackage create(File file) {
if (file == null || (file.exists() && file.isDirectory()))
throw new IllegalArgumentException("file");
if (file.exists()) {
throw new InvalidOperationException(
"This package (or file) already exists : use the open() method or delete the file.");
}
// Creates a new package
OPCPackage pkg = null;
pkg = new ZipPackage();
pkg.originalPackagePath = file.getAbsolutePath();
configurePackage(pkg);
return pkg;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
OPCPackage pack = new ZipPackage(path, access); // NOSONAR
boolean success = false;
if (pack.partList == null && access != PackageAccess.WRITE) {
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
OPCPackage pack = new ZipPackage(file, access);
try {
if (pack.partList == null && access != PackageAccess.WRITE) {
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Open an user provided {@link ZipEntrySource} with read-only permission.
* This method can be used to stream data into POI.
* Opposed to other open variants, the data is read as-is, e.g. there aren't
* any zip-bomb protection put in place.
*
* @param zipEntry the custom source
* @return A Package object
* @throws InvalidFormatException if a parsing error occur.
*/
public static OPCPackage open(ZipEntrySource zipEntry)
throws InvalidFormatException {
OPCPackage pack = new ZipPackage(zipEntry, PackageAccess.READ);
try {
if (pack.partList == null) {
pack.getParts();
}
// pack.originalPackagePath = file.getAbsolutePath();
return pack;
} catch (InvalidFormatException | RuntimeException e) {
IOUtils.closeQuietly(pack);
throw e;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Open a package.
*
* Note - uses quite a bit more memory than {@link #open(String)}, which
* doesn't need to hold the whole zip file in memory, and can take advantage
* of native methods
*
* @param in
* The InputStream to read the package from
* @return A PackageBase object
*
* @throws InvalidFormatException
*/
public static OPCPackage open(InputStream in) throws InvalidFormatException,
IOException {
OPCPackage pack = new ZipPackage(in, PackageAccess.READ_WRITE);
try {
if (pack.partList == null) {
pack.getParts();
}
} catch (InvalidFormatException | RuntimeException e) {
IOUtils.closeQuietly(pack);
throw e;
}
return pack;
}
内容来源于网络,如有侵权,请联系作者删除!