本文整理了Java中org.dihedron.core.zip.ZipArchive
类的一些代码示例,展示了ZipArchive
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipArchive
类的具体详情如下:
包路径:org.dihedron.core.zip.ZipArchive
类名称:ZipArchive
[英]Provides operations on a ZIP archive.
[中]提供对ZIP存档的操作。
代码示例来源:origin: org.dihedron.commons/dihedron-commons
/**
* Adds multiple files to the ZIP archive, given their names.
* @param filenames
* The Strings representing eth file names.
*/
public void addFiles(String[] filenames) throws IOException {
for (int i = 0; i < filenames.length; i++) {
addFile(null, filenames[i]);
}
}
代码示例来源:origin: org.dihedron.commons/base
/**
* Adds multiple files to the ZIP archive, given their names.
* @param files
* The File objects representing the files.
*/
public void addFiles(File[] files) throws IOException {
for (int i = 0; i < files.length; i++) {
addFile(null, files[i]);
}
}
代码示例来源:origin: org.dihedron.commons/dihedron-core
/**
* Adds multiple files to the ZIP archive, given their names.
* @param filenames
* The Strings representing eth file names.
*/
public void addFiles(String[] filenames) throws IOException {
for (int i = 0; i < filenames.length; i++) {
addFile(null, filenames[i]);
}
}
代码示例来源:origin: org.dihedron.commons/base
/**
* Adds multiple files to the ZIP archive, given their names.
* @param filenames
* The Strings representing eth file names.
*/
public void addFiles(String[] filenames) throws IOException {
for (int i = 0; i < filenames.length; i++) {
addFile(null, filenames[i]);
}
}
代码示例来源:origin: org.dihedron.commons/dihedron-core
/**
* Adds multiple files to the ZIP archive, given their names.
* @param files
* The File objects representing the files.
*/
public void addFiles(File[] files) throws IOException {
for (int i = 0; i < files.length; i++) {
addFile(null, files[i]);
}
}
代码示例来源:origin: org.dihedron.commons/dihedron-commons
/**
* Adds multiple files to the ZIP archive, given their names.
* @param files
* The File objects representing the files.
*/
public void addFiles(File[] files) throws IOException {
for (int i = 0; i < files.length; i++) {
addFile(null, files[i]);
}
}
代码示例来源:origin: org.dihedron.commons/dihedron-core
/**
* Adds a file to a ZIP archive, given its path.
*
* @param zipEntry
* the name of the entry in the archive; if null, the name of the original
* file is used.
* @param filename
* The path of a file to be added to the ZIP archive.
*/
public void addFile(String zipEntry, String filename) throws IOException {
addFile(zipEntry, new File(filename));
}
代码示例来源:origin: org.dihedron.commons/dihedron-core
/**
* Adds the contents of a ByteArrayOutputStream to the ZIP archive.
*
* @param zipEntry
* name of the entry in the archive.
* @param baos
* ByteArrayOutputStream to be added to the archive.
*/
public void addFile(String zipEntry, ByteArrayOutputStream baos) throws IOException {
addFile(zipEntry, baos.toByteArray());
}
代码示例来源:origin: org.dihedron.commons/dihedron-commons
/**
* Adds the contents of a ByteArrayOutputStream to the ZIP archive.
*
* @param zipEntry
* name of the entry in the archive.
* @param baos
* ByteArrayOutputStream to be added to the archive.
*/
public void addFile(String zipEntry, ByteArrayOutputStream baos) throws IOException {
addFile(zipEntry, baos.toByteArray());
}
代码示例来源:origin: org.dihedron.commons/base
/**
* Adds the contents of a ByteArrayOutputStream to the ZIP archive.
*
* @param zipEntry
* name of the entry in the archive.
* @param baos
* ByteArrayOutputStream to be added to the archive.
*/
public void addFile(String zipEntry, ByteArrayOutputStream baos) throws IOException {
addFile(zipEntry, baos.toByteArray());
}
代码示例来源:origin: org.dihedron.commons/base
/**
* Adds a file to a ZIP archive, given its path.
*
* @param zipEntry
* the name of the entry in the archive; if null, the name of the original
* file is used.
* @param filename
* The path of a file to be added to the ZIP archive.
*/
public void addFile(String zipEntry, String filename) throws IOException {
addFile(zipEntry, new File(filename));
}
代码示例来源:origin: org.dihedron.commons/dihedron-commons
/**
* Adds a file to a ZIP archive, given its path.
*
* @param zipEntry
* the name of the entry in the archive; if null, the name of the original
* file is used.
* @param filename
* The path of a file to be added to the ZIP archive.
*/
public void addFile(String zipEntry, String filename) throws IOException {
addFile(zipEntry, new File(filename));
}
代码示例来源:origin: org.dihedron.commons/dihedron-commons
/**
* Adds a text file (encoded as a list of strings) to the archive.
* @param zipEntry
* New entry name in the archive.
* @param text
* A list of Strings to be added as a text file to the archive.
* @return
*/
public void addTextFile(String zipEntry, String[] text) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(baos);
for (int i = 0; i < text.length; i++) {
// add the line
writer.write(text[i] + "\n");
}
writer.close();
addFile(zipEntry, baos);
}
代码示例来源:origin: org.dihedron.commons/base
/**
* Adds a text file (encoded as a list of strings) to the archive.
* @param zipEntry
* New entry name in the archive.
* @param text
* A list of Strings to be added as a text file to the archive.
* @return
*/
public void addTextFile(String zipEntry, String[] text) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(baos);
for (int i = 0; i < text.length; i++) {
// add the line
writer.write(text[i] + "\n");
}
writer.close();
addFile(zipEntry, baos);
}
代码示例来源:origin: org.dihedron.commons/dihedron-core
/**
* Adds a text file (encoded as a list of strings) to the archive.
* @param zipEntry
* New entry name in the archive.
* @param text
* A list of Strings to be added as a text file to the archive.
* @return
*/
public void addTextFile(String zipEntry, String[] text) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(baos);
for (int i = 0; i < text.length; i++) {
// add the line
writer.write(text[i] + "\n");
}
writer.close();
addFile(zipEntry, baos);
}
代码示例来源:origin: org.dihedron.commons/dihedron-core
if(value instanceof byte[]) {
logger.debug("adding '{}' defined as byte[]", zipEntry);
addFile(zipEntry, (byte[])value);
} else if(value instanceof ByteArrayOutputStream) {
logger.debug("adding '{}', defined as ByteArrayOutputStream", zipEntry);
addFile(zipEntry, (ByteArrayOutputStream)value);
} else if(value instanceof File) {
logger.debug("adding '{}', defined as File", zipEntry);
addFile(zipEntry, (File)value);
} else if(value instanceof String) {
logger.debug("adding '{}', defined as String (path)", zipEntry);
addFile(zipEntry, (String)value);
} else {
logger.error("unsupported data type for {}", zipEntry);
代码示例来源:origin: org.dihedron.commons/dihedron-commons
if(value instanceof byte[]) {
logger.debug("adding '{}' defined as byte[]", zipEntry);
addFile(zipEntry, (byte[])value);
} else if(value instanceof InputStream) {
logger.debug("adding '{}', defined as InputStream", zipEntry);
addFile(zipEntry, (InputStream)value);
} else if(value instanceof ByteArrayOutputStream) {
logger.debug("adding '{}', defined as ByteArrayOutputStream", zipEntry);
addFile(zipEntry, (ByteArrayOutputStream)value);
} else if(value instanceof File) {
logger.debug("adding '{}', defined as File", zipEntry);
addFile(zipEntry, (File)value);
} else if(value instanceof String) {
logger.debug("adding '{}', defined as String (path)", zipEntry);
addFile(zipEntry, (String)value);
} else {
logger.error("unsupported data type for {}", zipEntry);
代码示例来源:origin: org.dihedron.commons/base
if(value instanceof byte[]) {
logger.debug("adding '{}' defined as byte[]", zipEntry);
addFile(zipEntry, (byte[])value);
} else if(value instanceof ByteArrayOutputStream) {
logger.debug("adding '{}', defined as ByteArrayOutputStream", zipEntry);
addFile(zipEntry, (ByteArrayOutputStream)value);
} else if(value instanceof File) {
logger.debug("adding '{}', defined as File", zipEntry);
addFile(zipEntry, (File)value);
} else if(value instanceof String) {
logger.debug("adding '{}', defined as String (path)", zipEntry);
addFile(zipEntry, (String)value);
} else {
logger.error("unsupported data type for {}", zipEntry);
代码示例来源:origin: org.dihedron.commons/dihedron-commons
/**
* Adds a file to a ZIP archive.
*
* @param zipEntry
* the name of entry in the archive; if null, the name of the original
* file is used.
* @param file
* File object representing the file to be added to the archive.
*/
public void addFile(String zipEntry, File file) throws IOException {
String zipEntryName = Strings.isValid(zipEntry) ? zipEntry : file.getName();
logger.debug("adding '{}' as '{}'", file.getName(), zipEntryName);
try(InputStream input = new FileInputStream(file)) {
addFile(zipEntryName, input);
}
}
代码示例来源:origin: org.dihedron.commons/base
/**
* Adds a file to a ZIP archive.
*
* @param zipEntry
* the name of entry in the archive; if null, the name of the original
* file is used.
* @param file
* File object representing the file to be added to the archive.
*/
public void addFile(String zipEntry, File file) throws IOException {
String zipEntryName;
if(zipEntry == null || zipEntry.trim().length() == 0) {
zipEntryName = file.getName();
} else {
zipEntryName = zipEntry;
}
logger.debug("adding " + file.getName() + " as " + zipEntryName);
long size = file.length();
byte[] data = new byte[(int)size];
FileInputStream fis = new FileInputStream(file);
if(fis.read(data) != size) {
logger.error("error reading data into buffer");
}
fis.close();
addFile(zipEntryName, data);
}
内容来源于网络,如有侵权,请联系作者删除!