static public void uncompress( String fileInName, FileOutputStream out) throws IOException { long start = System.currentTimeMillis(); int total = 0; try (InputStream in = new UncompressInputStream( new FileInputStream(fileInName))) { byte[] buffer = new byte[100000]; while (true) { int bytesRead = in.read(buffer); if (bytesRead == -1) break; out.write(buffer, 0, bytesRead); total += bytesRead; } } if (debugTiming) { long end = System.currentTimeMillis(); System.err.println("Decompressed " + total + " bytes"); System.err.println("Time: " + (end - start) / 1000. + " seconds"); } }
static public void uncompress( String fileInName, FileOutputStream out) throws IOException { long start = System.currentTimeMillis(); InputStream in = new UncompressInputStream( new FileInputStream(fileInName)); int total = 0; byte[] buffer = new byte[100000]; while (true) { int bytesRead = in.read(buffer); if (bytesRead == -1) break; out.write(buffer, 0, bytesRead); total += bytesRead; } in.close(); out.close(); if (debugTiming) { long end = System.currentTimeMillis(); System.err.println("Decompressed " + total + " bytes"); System.err.println("Time: " + (end - start) / 1000. + " seconds"); } }
static public void uncompress( String fileInName, FileOutputStream out) throws IOException { long start = System.currentTimeMillis(); InputStream in = new UncompressInputStream( new FileInputStream(fileInName)); int total = 0; byte[] buffer = new byte[100000]; while (true) { int bytesRead = in.read(buffer); if (bytesRead == -1) break; out.write(buffer, 0, bytesRead); total += bytesRead; } in.close(); out.close(); if (debugTiming) { long end = System.currentTimeMillis(); System.err.println("Decompressed " + total + " bytes"); System.err.println("Time: " + (end - start) / 1000. + " seconds"); } }
/** test */ public static void main(String args[]) throws Exception { if (args.length != 1) { System.err.println("Usage: UncompressInputStream <file>"); System.exit(1); } InputStream in = new UncompressInputStream(new FileInputStream(args[0])); byte[] buf = new byte[100000]; int tot = 0; long beg = System.currentTimeMillis(); while (true) { int got = in.read(buf); if (got < 0) break; System.out.write(buf, 0, got); tot += got; } long end = System.currentTimeMillis(); System.err.println("Decompressed " + tot + " bytes"); System.err.println("Time: " + (end - beg) / 1000. + " seconds"); } }
/** test */ public static void main(String args[]) throws Exception { if (args.length != 1) { System.err.println("Usage: UncompressInputStream <file>"); System.exit(1); } InputStream in = new UncompressInputStream(new FileInputStream(args[0])); byte[] buf = new byte[100000]; int tot = 0; long beg = System.currentTimeMillis(); while (true) { int got = in.read(buf); if (got < 0) break; System.out.write(buf, 0, got); tot += got; } long end = System.currentTimeMillis(); System.err.println("Decompressed " + tot + " bytes"); System.err.println("Time: " + (end - beg) / 1000. + " seconds"); } }
/** test */ public static void main(String args[]) throws Exception { if (args.length != 1) { System.err.println("Usage: UncompressInputStream <file>"); System.exit(1); } try (InputStream in = new UncompressInputStream(new FileInputStream(args[0]))) { byte[] buf = new byte[100000]; int tot = 0; long beg = System.currentTimeMillis(); while (true) { int got = in.read(buf); if (got < 0) break; System.out.write(buf, 0, got); tot += got; } long end = System.currentTimeMillis(); System.err.println("Decompressed " + tot + " bytes"); System.err.println("Time: " + (end - beg) / 1000. + " seconds"); } } }
private static InputStream openInputStream(File file) throws IOException { String fileName = file.getName().toLowerCase(); InputStream is = new BufferedInputStream(new FileInputStream(file)); if (fileName.endsWith(".z")) { is = new UncompressInputStream(is); } else if (fileName.endsWith(".zip")) { ZipInputStream zin = new ZipInputStream(is); ZipEntry ze = zin.getNextEntry(); if (ze != null) { is = zin; } } else if (fileName.endsWith(".bz2")) { is = new CBZip2InputStream(is, true); } else if (fileName.endsWith(".gzip") || fileName.endsWith(".gz")) { is = new GZIPInputStream(is); } return is; }
in = new UncompressInputStream(new FileInputStream(filename)); copy(in, fout, 100000); if (debugCompress) System.out.println("uncompressed " + filename + " to " + uncompressedFile);
try (InputStream in = new UncompressInputStream(new FileInputStream(filename))) { copy(in, fout, 100000);
in = new UncompressInputStream(new FileInputStream(filename)); copy(in, fout, 100000); if (debugCompress) System.out.println("uncompressed " + filename + " to " + uncompressedFile);
InputStream inputStream = new BufferedInputStream(new FileInputStream(filename), COPY_BUFFER_LENGTH); if (suffix.equalsIgnoreCase("Z")) { in = new UncompressInputStream(inputStream); copy(in, fout, COPY_BUFFER_LENGTH); LOG.fine("uncompressed " + filename + " to " + uncompressedFile);