本文整理匯總了Java中org.apache.commons.compress.archivers.cpio.CpioArchiveOutputStream類的典型用法代碼示例。如果您正苦於以下問題:Java CpioArchiveOutputStream類的具體用法?Java CpioArchiveOutputStream怎麽用?Java CpioArchiveOutputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CpioArchiveOutputStream類屬於org.apache.commons.compress.archivers.cpio包,在下文中一共展示了CpioArchiveOutputStream類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: PayloadRecorder
import org.apache.commons.compress.archivers.cpio.CpioArchiveOutputStream; //導入依賴的package包/類
public PayloadRecorder ( final boolean autoFinish ) throws IOException
{
this.autoFinish = autoFinish;
this.tempFile = Files.createTempFile ( "rpm-", null );
try
{
this.fileStream = new BufferedOutputStream ( Files.newOutputStream ( this.tempFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING ) );
this.payloadCounter = new CountingOutputStream ( this.fileStream );
final GZIPOutputStream payloadStream = new GZIPOutputStream ( this.payloadCounter );
this.archiveCounter = new CountingOutputStream ( payloadStream );
// setup archive stream
this.archiveStream = new CpioArchiveOutputStream ( this.archiveCounter, CpioConstants.FORMAT_NEW, 4, "UTF-8" );
}
catch ( final IOException e )
{
Files.deleteIfExists ( this.tempFile );
throw e;
}
}
示例2: compressData
import org.apache.commons.compress.archivers.cpio.CpioArchiveOutputStream; //導入依賴的package包/類
/**
* Compress data
*
* @param fileCompressor
* FileCompressor object
* @return
* @throws Exception
*/
@Override
public byte[] compressData(FileCompressor fileCompressor) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CpioArchiveOutputStream aos = new CpioArchiveOutputStream(baos);
try {
for (BinaryFile binaryFile : fileCompressor.getMapBinaryFile()
.values()) {
CpioArchiveEntry entry = new CpioArchiveEntry(
binaryFile.getDesPath(), binaryFile.getActualSize());
aos.putArchiveEntry(entry);
aos.write(binaryFile.getData());
aos.closeArchiveEntry();
}
aos.flush();
aos.finish();
} catch (Exception e) {
FileCompressor.LOGGER.error("Error on compress data", e);
} finally {
aos.close();
baos.close();
}
return baos.toByteArray();
}
示例3: createArchiveOutputStream
import org.apache.commons.compress.archivers.cpio.CpioArchiveOutputStream; //導入依賴的package包/類
ArchiveOutputStream createArchiveOutputStream() throws IOException {
switch (format) {
case CPIO:
return new CpioArchiveOutputStream(output);
case JAR:
return new JarArchiveOutputStream(output);
case TAR:
return new TarArchiveOutputStream(output);
case ZIP:
return new ZipArchiveOutputStream(output);
}
// Normally, this code is not called because of the above switch.
throw new IOException("Format is configured.");
}