gpt4 book ai didi

org.dihedron.core.zip.ZipArchive.addFile()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 21:53:31 28 4
gpt4 key购买 nike

本文整理了Java中org.dihedron.core.zip.ZipArchive.addFile()方法的一些代码示例,展示了ZipArchive.addFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipArchive.addFile()方法的具体详情如下:
包路径:org.dihedron.core.zip.ZipArchive
类名称:ZipArchive
方法名:addFile

ZipArchive.addFile介绍

[英]Adds the contents of a ByteArrayOutputStream to the ZIP archive.
[中]将ByteArrayOutputStream的内容添加到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/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);
}

代码示例来源:origin: org.dihedron.commons/dihedron-core

/**
 * 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);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com