/** * Returns the IOException responsible for the failure of a copy operation. * @return The IOException responsible for the failure of a copy operation. */ public IOException getIOException() { return (IOException) getCause(); // cast is OK because it was initialised with an IOException } }
/** * Creates a new CopyStreamException instance. * @param message A message describing the error. * @param bytesTransferred The total number of bytes transferred before * an exception was thrown in a copy operation. * @param exception The IOException thrown during a copy operation. */ public CopyStreamException(String message, long bytesTransferred, IOException exception) { super(message); initCause(exception); // merge this into super() call once we need 1.6+ totalBytesTransferred = bytesTransferred; }
throw new CopyStreamException("IOException caught while copying.", total, e);
throw new CopyStreamException("IOException caught while copying.", total, e);
public static final long copyStream(InputStream source, OutputStream dest, int bufferSize, long streamSize, CopyStreamListener listener, boolean flush) throws CopyStreamException { int bytes; long total = 0; byte[] buffer = new byte[bufferSize >= 0 ? bufferSize : DEFAULT_COPY_BUFFER_SIZE]; try { while ((bytes = source.read(buffer)) != -1) { .... } } catch (IOException e) { throw new CopyStreamException("IOException caught while copying.", total, e); } return total; }
throw new CopyStreamException("IOException caught while copying.", total, e); throw new CopyStreamException("IOException caught while copying.", total, e);
throw new CopyStreamException("IOException caught while copying.", total, e); throw new CopyStreamException("IOException caught while copying.", total, e);