/** * Closes the proxied input stream and, if so configured, the associated * output stream. An exception thrown from one stream will not prevent * closing of the other stream. * * @throws IOException if either of the streams could not be closed */ @Override public void close() throws IOException { try { super.close(); } finally { if (closeBranch) { branch.close(); } } }
/** * Reads a single byte from the proxied input stream and writes it to * the associated output stream. * * @return next byte from the stream, or -1 if the stream has ended * @throws IOException if the stream could not be read (or written) */ @Override public int read() throws IOException { final int ch = super.read(); if (ch != EOF) { branch.write(ch); } return ch; }
/** * Skips the stream over the specified number of bytes, adding the skipped * amount to the count. * * @param length the number of bytes to skip * @return the actual number of bytes skipped * @throws IOException if an I/O error occurs * @see java.io.InputStream#skip(long) */ @Override public synchronized long skip(final long length) throws IOException { final long skip = super.skip(length); this.count += skip; return skip; }
/** * Invokes the delegate's <code>read(byte[])</code> method. * @param bts the buffer to read the bytes into * @return the number of bytes read or EOF if the end of stream * @throws IOException if an I/O error occurs */ @Override public int read(final byte[] bts) throws IOException { try { beforeRead(bts != null ? bts.length : 0); final int n = in.read(bts); afterRead(n); return n; } catch (final IOException e) { handleIOException(e); return EOF; } }
/** * Invokes the delegate's <code>reset()</code> method. * @throws IOException if an I/O error occurs */ @Override public synchronized void reset() throws IOException { try { in.reset(); } catch (final IOException e) { handleIOException(e); } }
/** * Invokes the delegate's <code>read()</code> method. * @return the byte read or -1 if the end of stream * @throws IOException if an I/O error occurs */ @Override public int read() throws IOException { try { beforeRead(1); final int b = in.read(); afterRead(b != EOF ? 1 : EOF); return b; } catch (final IOException e) { handleIOException(e); return EOF; } }
/** * Invokes the delegate's <code>close()</code> method. * @throws IOException if an I/O error occurs */ @Override public void close() throws IOException { try { in.close(); } catch (final IOException e) { handleIOException(e); } }
/** * Reads bytes from the proxied input stream and writes the read bytes * to the associated output stream. * * @param bts byte buffer * @return number of bytes read, or -1 if the stream has ended * @throws IOException if the stream could not be read (or written) */ @Override public int read(final byte[] bts) throws IOException { final int n = super.read(bts); if (n != EOF) { branch.write(bts, 0, n); } return n; }
@Override public void close() throws IOException { IOException ioe = null; try { super.close(); } catch (final IOException e) { ioe = e; } if (ioe == null) { noteClosed(); } else { noteError(ioe); } }
/** * Invokes the delegate's <code>read(byte[], int, int)</code> method. * @param bts the buffer to read the bytes into * @param off The start offset * @param len The number of bytes to read * @return the number of bytes read or -1 if the end of stream * @throws IOException if an I/O error occurs */ @Override public int read(final byte[] bts, final int off, final int len) throws IOException { try { beforeRead(len); final int n = in.read(bts, off, len); afterRead(n); return n; } catch (final IOException e) { handleIOException(e); return EOF; } }
/** * Skips the stream over the specified number of bytes, adding the skipped * amount to the count. * * @param length the number of bytes to skip * @return the actual number of bytes skipped * @throws IOException if an I/O error occurs * @see java.io.InputStream#skip(long) */ public long skip(final long length) throws IOException { final long skip = super.skip(length); this.count += skip; return skip; }
/** * Invokes the delegate's <code>skip(long)</code> method. * @param ln the number of bytes to skip * @return the actual number of bytes skipped * @throws IOException if an I/O error occurs */ @Override public long skip(final long ln) throws IOException { try { return in.skip(ln); } catch (final IOException e) { handleIOException(e); return 0; } }
/** * Reads bytes from the proxied input stream and writes the read bytes * to the associated output stream. * * @param bts byte buffer * @param st start offset within the buffer * @param end maximum number of bytes to read * @return number of bytes read, or -1 if the stream has ended * @throws IOException if the stream could not be read (or written) */ @Override public int read(final byte[] bts, final int st, final int end) throws IOException { final int n = super.read(bts, st, end); if (n != -1) { branch.write(bts, st, n); } return n; }
@Override public void close() throws IOException { super.close(); closeWhispering(sftp, this); } }
/** * Invokes the delegate's <code>read()</code> method. * @return the byte read or -1 if the end of stream * @throws IOException if an I/O error occurs */ @Override public int read() throws IOException { try { beforeRead(1); final int b = in.read(); afterRead(b != EOF ? 1 : EOF); return b; } catch (final IOException e) { handleIOException(e); return EOF; } }
/** * Skips the stream over the specified number of bytes, adding the skipped * amount to the count. * * @param length the number of bytes to skip * @return the actual number of bytes skipped * @throws IOException if an I/O error occurs * @see java.io.InputStream#skip(long) */ public long skip(final long length) throws IOException { final long skip = super.skip(length); this.count += skip; return skip; }
/** * Invokes the delegate's <code>available()</code> method. * @return the number of available bytes * @throws IOException if an I/O error occurs */ @Override public int available() throws IOException { try { return super.available(); } catch (final IOException e) { handleIOException(e); return 0; } }
/** * Reads the next byte of data adding to the count of bytes received * if a byte is successfully read. * * @return the byte read, -1 if end of stream * @throws IOException if an I/O error occurs * @see java.io.InputStream#read() */ public int read() throws IOException { int found = super.read(); this.count += (found >= 0) ? 1 : 0; return found; }
@Override public void close() throws IOException { super.close(); closeWhispering(sftp, this); } }
/** * Invokes the delegate's <code>read()</code> method. * @return the byte read or -1 if the end of stream * @throws IOException if an I/O error occurs */ @Override public int read() throws IOException { try { beforeRead(1); int b = in.read(); afterRead(b != -1 ? 1 : -1); return b; } catch (IOException e) { handleIOException(e); return -1; } }