/** * copy file to output stream, specify internal buffer size * * @param fileIn copy this file * @param out copy to this stream * @param bufferSize internal buffer size. * @throws java.io.IOException on io error */ static public void copyFileB(File fileIn, OutputStream out, int bufferSize) throws IOException { try (FileInputStream fin = new FileInputStream(fileIn)) { InputStream in = new BufferedInputStream(fin); IO.copyB(in, out, bufferSize); } }
/** * copy file to output stream, specify internal buffer size * * @param fileIn copy this file * @param out copy to this stream * @param bufferSize internal buffer size. * @throws java.io.IOException on io error */ static public void copyFileB(File fileIn, OutputStream out, int bufferSize) throws IOException { try (FileInputStream fin = new FileInputStream(fileIn)) { InputStream in = new BufferedInputStream(fin); IO.copyB(in, out, bufferSize); } }
/** * copy file to output stream, specify internal buffer size * * @param fileIn copy this file * @param out copy to this stream * @param bufferSize internal buffer size. * @throws java.io.IOException on io error */ static public void copyFileB(File fileIn, OutputStream out, int bufferSize) throws IOException { InputStream in = null; try { in = new BufferedInputStream(new FileInputStream(fileIn)); IO.copyB(in, out, bufferSize); } finally { if (null != in) in.close(); } }
/** * inflate data * * @param compressed compressed data * @return uncompressed data * @throws IOException on I/O error */ private byte[] inflate(byte[] compressed) throws IOException { // run it through the Inflator ByteArrayInputStream in = new ByteArrayInputStream(compressed); java.util.zip.Inflater inflater = new java.util.zip.Inflater(); java.util.zip.InflaterInputStream inflatestream = new java.util.zip.InflaterInputStream(in, inflater, inflatebuffersize); int len = Math.min(8 * compressed.length, MAX_ARRAY_LEN); ByteArrayOutputStream out = new ByteArrayOutputStream(len); // Fixes KXL-349288 IO.copyB(inflatestream, out, len); byte[] uncomp = out.toByteArray(); if (debug || debugFilter) System.out.println(" inflate bytes in= " + compressed.length + " bytes out= " + uncomp.length); return uncomp; }
count = IO.copy2null(bis, bufferSize); else count = IO.copyB(bis, out, bufferSize);
count = IO.copy2null(bis, bufferSize); else count = IO.copyB(bis, out, bufferSize);
count = IO.copy2null(is, bufferSize); else count = IO.copyB(is, out, bufferSize);
static public void copyFile(String filenameIn, String filenameOut, boolean buffer) throws IOException { long lenIn = new File(filenameIn).length(); if (debug) System.out.println("read " + filenameIn + " len = " + lenIn); InputStream in = new FileInputStream(filenameIn); if (buffer) new BufferedInputStream(in, 10000); OutputStream out = new FileOutputStream(filenameOut); if (buffer) out = new BufferedOutputStream(out, 1000); long start = System.currentTimeMillis(); IO.copyB(in, out, 10000); out.flush(); double took = .001 * (System.currentTimeMillis() - start); out.close(); in.close(); long lenOut = new File(filenameOut).length(); if (debug) System.out.println(" write file= " + filenameOut + " len = " + lenOut); double rate = lenIn / took / (1000 * 1000); String name = buffer ? "buffer" : "no buffer"; System.out.println(" copy (" + name + ") took = " + took + " sec; rate = " + rate + "Mb/sec"); }
if (is != null) { FileOutputStream fout = new FileOutputStream(file); IO.copyB(is, fout, buffer_size); // cache it fout.close(); InputStream fin = new BufferedInputStream( new FileInputStream(file), 50000);
if (is != null) { try (FileOutputStream fout = new FileOutputStream(file)) { IO.copyB(is, fout, buffer_size); // cache it
if (is != null) { try (FileOutputStream fout = new FileOutputStream(file)) { IO.copyB(is, fout, buffer_size); // cache it