List of usage examples for org.apache.commons.compress.archivers.cpio CpioArchiveEntry getSize
public long getSize()
From source file:com.espringtran.compressor4j.processor.CpioProcessor.java
/** * Read from compressed file/*from ww w . j a v a2s . c om*/ * * @param srcPath * path of compressed file * @param fileCompressor * FileCompressor object * @throws Exception */ @Override public void read(String srcPath, FileCompressor fileCompressor) throws Exception { long t1 = System.currentTimeMillis(); byte[] data = FileUtil.convertFileToByte(srcPath); ByteArrayInputStream bais = new ByteArrayInputStream(data); CpioArchiveInputStream ais = new CpioArchiveInputStream(bais); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { byte[] buffer = new byte[1024]; int readByte; CpioArchiveEntry entry = ais.getNextCPIOEntry(); while (entry != null && entry.getSize() > 0) { long t2 = System.currentTimeMillis(); baos = new ByteArrayOutputStream(); readByte = ais.read(buffer); while (readByte != -1) { baos.write(buffer, 0, readByte); readByte = ais.read(buffer); } BinaryFile binaryFile = new BinaryFile(entry.getName(), baos.toByteArray()); fileCompressor.addBinaryFile(binaryFile); LogUtil.createAddFileLog(fileCompressor, binaryFile, t2, System.currentTimeMillis()); entry = ais.getNextCPIOEntry(); } } catch (Exception e) { FileCompressor.LOGGER.error("Error on get compressor file", e); } finally { baos.close(); ais.close(); bais.close(); } LogUtil.createReadLog(fileCompressor, srcPath, data.length, t1, System.currentTimeMillis()); }
From source file:de.dentrassi.rpm.tests.InputStreamTest.java
private void dumpEntry(final CpioArchiveEntry entry) { System.out.format("-----------------------------------%n"); System.out.format(" %s%n", entry.getName()); System.out.format(" Size: %s%n", entry.getSize()); }
From source file:org.eclipse.packagedrone.utils.rpm.app.Dumper.java
private static void dumpEntry(final CpioArchiveEntry entry) { System.out.format("-----------------------------------%n"); System.out.format(" %s%n", entry.getName()); System.out.format(" Size: %s, Chksum: %016x, Align: %s, Inode: %016x, Mode: %08o, NoL: %s, Device: %s.%s%n", entry.getSize(), entry.getChksum(), entry.getAlignmentBoundary(), entry.getInode(), entry.getMode(), entry.getNumberOfLinks(), entry.getDeviceMaj(), entry.getDeviceMin()); }