gpt4 book ai didi

proguard.io.ZipOutput类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 03:38:31 26 4
gpt4 key购买 nike

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

ZipOutput介绍

[英]This class writes zip data to a given output stream. It returns a new output stream for each zip entry that is opened. An entry can be compressed or uncompressed. Uncompressed entries can be aligned to a multiple of a given number of bytes. Multiple entries and output streams can be open at the same time. The entries are added to the central directory in the order in which they are opened, but the corresponding data are only written when their output streams are closed. The code automatically computes the CRC and lengths of the data, for compressed and uncompressed data.
[中]此类将zip数据写入给定的输出流。它为每个打开的zip条目返回一个新的输出流。条目可以被压缩或解压缩。未压缩的条目可以与给定字节数的倍数对齐。可以同时打开多个条目和输出流。条目按打开顺序添加到中心目录,但只有在其输出流关闭时,才会写入相应的数据。该代码自动计算压缩和未压缩数据的CRC和数据长度。

代码示例

代码示例来源:origin: johnjohndoe/ProGuard

/**
 * Closes the zip output, if any.
 */
protected void finish() throws IOException
{
  // Finish the zip output, if any.
  if (currentZipOutput != null)
  {
    // Close the zip output and its underlying output stream.
    currentZipOutput.close();
    currentParentEntry = null;
    currentZipOutput   = null;
  }
}

代码示例来源:origin: syedlopez/proguard

/**
 * Creates a new zip entry, returning an output stream to write its data.
 * It is the caller's responsibility to close the output stream.
 * @param name             the name of the zip entry.
 * @param compress         specifies whether the entry should be compressed.
 * @param modificationTime the modification date and time of the zip entry,
 *                         in DOS format.
 * @return                 an output stream for writing the data of the
 *                         zip entry.
 */
public OutputStream createOutputStream(String  name,
                    boolean compress,
                    int     modificationTime)
throws IOException
{
  return createOutputStream(name,
               compress,
               modificationTime,
               null,
               null);
}

代码示例来源:origin: syedlopez/proguard

/**
 * Closes the zip archive, also closing the underlying output stream.
 */
public void close() throws IOException
{
  // Write the central directory.
  writeStartOfCentralDirectory();
  for (int index = 0; index < zipEntries.size(); index++)
  {
    ZipEntry entry = (ZipEntry)zipEntries.get(index);
    entry.writeCentralDirectoryFileHeader();
  }
  writeEndOfCentralDirectory();
  // Close the underlying output stream.
  outputStream.close();
  // Make sure the archive can't be used any further.
  outputStream  = null;
  zipEntries    = null;
  zipEntryNames = null;
}

代码示例来源:origin: syedlopez/proguard

writeInt(MAGIC_END_OF_CENTRAL_DIRECTORY);
writeShort(0);                    // Number of this disk.
writeShort(0);                    // Number of disk with central directory.
writeShort(zipEntries.size());    // Number of records on this disk.
writeShort(zipEntries.size());    // Total number of records.
writeInt(centralDirectorySize);   // Size of central directory, in bytes.
writeInt(centralDirectoryOffset); // Offset of central directory.
  writeShort(0);
  writeShort(commentBytes.length);
  outputStream.write(commentBytes);

代码示例来源:origin: syedlopez/proguard

new ZipOutput(new FileOutputStream(args[0]), null, "Main file comment", 4);
  new PrintWriter(output.createOutputStream("file1.txt", false, 0, new byte[] { 0x34, 0x12, 4, 0, 0x48, 0x65, 0x6c, 0x6c, 0x6f }, "Comment"));
printWriter1.println("This is file 1.");
printWriter1.println("Hello, world!");
  new PrintWriter(output.createOutputStream("file2.txt", true, 0, null, "Another comment"));
printWriter2.println("This is file 2.");
printWriter2.println("Hello, world!");
  new PrintWriter(output.createOutputStream("file3.txt", false, 0, null, "Last comment"));
printWriter3.println("This is file 3.");
printWriter3.println("Hello, world!");
printWriter3.close();
output.close();

代码示例来源:origin: johnjohndoe/ProGuard

/**
 * Sets up the zip output for the given parent entry.
 */
protected void setUp(DataEntry dataEntry) throws IOException
{
  if (currentZipOutput == null)
  {
    // Create a new zip output.
    currentParentEntry = dataEntry.getParent();
    currentZipOutput   = new ZipOutput(dataEntryWriter.createOutputStream(currentParentEntry),
                      header,
                      null,
                      1);
  }
}

代码示例来源:origin: syedlopez/proguard

new ZipOutput(new FileOutputStream(args[0]), null, "Main file comment", 4);
  new PrintWriter(output.createOutputStream("file1.txt", false, 0, new byte[] { 0x34, 0x12, 4, 0, 0x48, 0x65, 0x6c, 0x6c, 0x6f }, "Comment"));
printWriter1.println("This is file 1.");
printWriter1.println("Hello, world!");
  new PrintWriter(output.createOutputStream("file2.txt", true, 0, null, "Another comment"));
printWriter2.println("This is file 2.");
printWriter2.println("Hello, world!");
  new PrintWriter(output.createOutputStream("file3.txt", false, 0, null, "Last comment"));
printWriter3.println("This is file 3.");
printWriter3.println("Hello, world!");
printWriter3.close();
output.close();

代码示例来源:origin: syedlopez/proguard

writeInt(MAGIC_END_OF_CENTRAL_DIRECTORY);
writeShort(0);                    // Number of this disk.
writeShort(0);                    // Number of disk with central directory.
writeShort(zipEntries.size());    // Number of records on this disk.
writeShort(zipEntries.size());    // Total number of records.
writeInt(centralDirectorySize);   // Size of central directory, in bytes.
writeInt(centralDirectoryOffset); // Offset of central directory.
  writeShort(0);
  writeShort(commentBytes.length);
  outputStream.write(commentBytes);

代码示例来源:origin: johnjohndoe/ProGuard

/**
 * Sets up the zip output for the given parent entry.
 */
protected void setUp(DataEntry dataEntry) throws IOException
{
  if (currentZipOutput == null)
  {
    // Create a new zip output.
    currentParentEntry = dataEntry.getParent();
    currentZipOutput   = new ZipOutput(dataEntryWriter.createOutputStream(currentParentEntry),
                      header,
                      null,
                      1);
  }
}

代码示例来源:origin: syedlopez/proguard

new ZipOutput(new FileOutputStream(args[0]), null, "Main file comment", 4);
  new PrintWriter(output.createOutputStream("file1.txt", false, 0, new byte[] { 0x34, 0x12, 4, 0, 0x48, 0x65, 0x6c, 0x6c, 0x6f }, "Comment"));
printWriter1.println("This is file 1.");
printWriter1.println("Hello, world!");
  new PrintWriter(output.createOutputStream("file2.txt", true, 0, null, "Another comment"));
printWriter2.println("This is file 2.");
printWriter2.println("Hello, world!");
  new PrintWriter(output.createOutputStream("file3.txt", false, 0, null, "Last comment"));
printWriter3.println("This is file 3.");
printWriter3.println("Hello, world!");
printWriter3.close();
output.close();

代码示例来源:origin: syedlopez/proguard

/**
 * Closes the zip archive, also closing the underlying output stream.
 */
public void close() throws IOException
{
  // Write the central directory.
  writeStartOfCentralDirectory();
  for (int index = 0; index < zipEntries.size(); index++)
  {
    ZipEntry entry = (ZipEntry)zipEntries.get(index);
    entry.writeCentralDirectoryFileHeader();
  }
  writeEndOfCentralDirectory();
  // Close the underlying output stream.
  outputStream.close();
  // Make sure the archive can't be used any further.
  outputStream  = null;
  zipEntries    = null;
  zipEntryNames = null;
}

代码示例来源:origin: syedlopez/proguard

writeInt(MAGIC_END_OF_CENTRAL_DIRECTORY);
writeShort(0);                    // Number of this disk.
writeShort(0);                    // Number of disk with central directory.
writeShort(zipEntries.size());    // Number of records on this disk.
writeShort(zipEntries.size());    // Total number of records.
writeInt(centralDirectorySize);   // Size of central directory, in bytes.
writeInt(centralDirectoryOffset); // Offset of central directory.
  writeShort(0);
  writeShort(commentBytes.length);
  outputStream.write(commentBytes);

代码示例来源:origin: syedlopez/proguard

/**
 * Creates a new zip entry, returning an output stream to write its data.
 * It is the caller's responsibility to close the output stream.
 * @param name             the name of the zip entry.
 * @param compress         specifies whether the entry should be compressed.
 * @param modificationTime the modification date and time of the zip entry,
 *                         in DOS format.
 * @return                 an output stream for writing the data of the
 *                         zip entry.
 */
public OutputStream createOutputStream(String  name,
                    boolean compress,
                    int     modificationTime)
throws IOException
{
  return createOutputStream(name,
               compress,
               modificationTime,
               null,
               null);
}

代码示例来源:origin: johnjohndoe/ProGuard

/**
 * Closes the zip output, if any.
 */
protected void finish() throws IOException
{
  // Finish the zip output, if any.
  if (currentZipOutput != null)
  {
    // Close the zip output and its underlying output stream.
    currentZipOutput.close();
    currentParentEntry = null;
    currentZipOutput   = null;
  }
}

代码示例来源:origin: johnjohndoe/ProGuard

/**
 * Sets up the zip output for the given parent entry.
 */
protected void setUp(DataEntry dataEntry) throws IOException
{
  if (currentZipOutput == null)
  {
    // Create a new zip output.
    currentParentEntry = dataEntry.getParent();
    currentZipOutput   = new ZipOutput(dataEntryWriter.createOutputStream(currentParentEntry),
                      header,
                      null,
                      1);
  }
}

代码示例来源:origin: syedlopez/proguard

/**
 * Closes the zip archive, also closing the underlying output stream.
 */
public void close() throws IOException
{
  // Write the central directory.
  writeStartOfCentralDirectory();
  for (int index = 0; index < zipEntries.size(); index++)
  {
    ZipEntry entry = (ZipEntry)zipEntries.get(index);
    entry.writeCentralDirectoryFileHeader();
  }
  writeEndOfCentralDirectory();
  // Close the underlying output stream.
  outputStream.close();
  // Make sure the archive can't be used any further.
  outputStream  = null;
  zipEntries    = null;
  zipEntryNames = null;
}

代码示例来源:origin: syedlopez/proguard

/**
 * Creates a new zip entry, returning an output stream to write its data.
 * It is the caller's responsibility to close the output stream.
 * @param name             the name of the zip entry.
 * @param compress         specifies whether the entry should be compressed.
 * @param modificationTime the modification date and time of the zip entry,
 *                         in DOS format.
 * @return                 an output stream for writing the data of the
 *                         zip entry.
 */
public OutputStream createOutputStream(String  name,
                    boolean compress,
                    int     modificationTime)
throws IOException
{
  return createOutputStream(name,
               compress,
               modificationTime,
               null,
               null);
}

代码示例来源:origin: johnjohndoe/ProGuard

/**
 * Closes the zip output, if any.
 */
protected void finish() throws IOException
{
  // Finish the zip output, if any.
  if (currentZipOutput != null)
  {
    // Close the zip output and its underlying output stream.
    currentZipOutput.close();
    currentParentEntry = null;
    currentZipOutput   = null;
  }
}

代码示例来源:origin: johnjohndoe/ProGuard

public boolean createDirectory(DataEntry dataEntry) throws IOException
{
  finishIfNecessary(dataEntry);
  setUp(dataEntry);
  // Did we get a zip output?
  if (currentZipOutput == null)
  {
    return false;
  }
  // Get the directory entry name.
  String name = dataEntry.getName() + ClassConstants.PACKAGE_SEPARATOR;
  // Create a new directory entry.
  OutputStream outputStream =
    currentZipOutput.createOutputStream(name,
                      false,
                      modificationTime);
  outputStream.close();
  return true;
}

代码示例来源:origin: johnjohndoe/ProGuard

public boolean createDirectory(DataEntry dataEntry) throws IOException
{
  finishIfNecessary(dataEntry);
  setUp(dataEntry);
  // Did we get a zip output?
  if (currentZipOutput == null)
  {
    return false;
  }
  // Get the directory entry name.
  String name = dataEntry.getName() + ClassConstants.PACKAGE_SEPARATOR;
  // Create a new directory entry.
  OutputStream outputStream =
    currentZipOutput.createOutputStream(name,
                      false,
                      modificationTime);
  outputStream.close();
  return true;
}

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