public long copy() throws IOException { final byte[] buf = new byte[bufSize]; long count = 0; int read = 0; final long startTime = System.currentTimeMillis(); if (length == -1) { while ((read = in.read(buf)) != -1) { count += write(buf, count, read); } } else { while (count < length && (read = in.read(buf, 0, (int) Math.min(bufSize, length - count))) != -1) { count += write(buf, count, read); } } if (!keepFlushing) out.flush(); final double timeSeconds = (System.currentTimeMillis() - startTime) / 1000.0; final double sizeKiB = count / 1024.0; log.debug(String.format("%1$,.1f KiB transferred in %2$,.1f seconds (%3$,.2f KiB/s)", sizeKiB, timeSeconds, (sizeKiB / timeSeconds))); if (length != -1 && read == -1) throw new IOException("Encountered EOF, could not transfer " + length + " bytes"); return count; }
public long copy() throws IOException { final byte[] buf = new byte[bufSize]; long count = 0; int read = 0; final long startTime = System.currentTimeMillis(); if (length == -1) { while ((read = in.read(buf)) != -1) count = write(buf, count, read); } else { while (count < length && (read = in.read(buf, 0, (int) Math.min(bufSize, length - count))) != -1) count = write(buf, count, read); } if (!keepFlushing) out.flush(); final double timeSeconds = (System.currentTimeMillis() - startTime) / 1000.0; final double sizeKiB = count / 1024.0; log.info("{} KiB transferred in {} seconds ({} KiB/s)", sizeKiB, timeSeconds, (sizeKiB / timeSeconds)); if (length != -1 && read == -1) throw new IOException("Encountered EOF, could not transfer " + length + " bytes"); return count; }
public long copy() throws IOException { final byte[] buf = new byte[bufSize]; long count = 0; int read = 0; final long startTime = System.currentTimeMillis(); if (length == -1) { while ((read = in.read(buf)) != -1) { count += write(buf, count, read); } } else { while (count < length && (read = in.read(buf, 0, (int) Math.min(bufSize, length - count))) != -1) { count += write(buf, count, read); } } if (!keepFlushing) out.flush(); final double timeSeconds = (System.currentTimeMillis() - startTime) / 1000.0; final double sizeKiB = count / 1024.0; log.debug(String.format("%1$,.1f KiB transferred in %2$,.1f seconds (%3$,.2f KiB/s)", sizeKiB, timeSeconds, (sizeKiB / timeSeconds))); if (length != -1 && read == -1) throw new IOException("Encountered EOF, could not transfer " + length + " bytes"); return count; }