/** * @param command the command to send * @param remote the remote file name * @return the output stream to write to * @throws IOException on error * @since 3.1 */ protected OutputStream _storeFileStream(String command, String remote) throws IOException { Socket socket = _openDataConnection_(command, remote); if (socket == null) { return null; } final OutputStream output; if (__fileType == ASCII_FILE_TYPE) { // We buffer ascii transfers because the buffering has to // be interposed between ToNetASCIIOutputSream and the underlying // socket output stream. We don't buffer binary transfers // because we don't want to impose a buffering policy on the // programmer if possible. Programmers can decide on their // own if they want to wrap the SocketOutputStream we return // for file types other than ASCII. output = new ToNetASCIIOutputStream(getBufferedOutputStream(socket.getOutputStream())); } else { output = socket.getOutputStream(); } return new org.apache.commons.net.io.SocketOutputStream(socket, output); }
/*** * Writes a byte array to the stream. * * @param buffer The byte array to write. * @throws IOException If an error occurs while writing to the underlying * stream. ***/ @Override public synchronized void write(byte buffer[]) throws IOException { write(buffer, 0, buffer.length); }
output = new ToNetASCIIOutputStream(getBufferedOutputStream(socket.getOutputStream())); } else { output = getBufferedOutputStream(socket.getOutputStream());
/*** * Writes a number of bytes from a byte array to the stream starting from * a given offset. * * @param buffer The byte array to write. * @param offset The offset into the array at which to start copying data. * @param length The number of bytes to write. * @throws IOException If an error occurs while writing to the underlying * stream. ***/ @Override public synchronized void write(byte buffer[], int offset, int length) throws IOException { while (length-- > 0) { write(buffer[offset++]); } }
private OutputStream __storeFileStream(int command, String remote) throws IOException { OutputStream output; Socket socket; if ((socket = _openDataConnection_(command, remote)) == null) return null; output = socket.getOutputStream(); if (__fileType == ASCII_FILE_TYPE) { // We buffer ascii transfers because the buffering has to // be interposed between ToNetASCIIOutputSream and the underlying // socket output stream. We don't buffer binary transfers // because we don't want to impose a buffering policy on the // programmer if possible. Programmers can decide on their // own if they want to wrap the SocketOutputStream we return // for file types other than ASCII. output = new BufferedOutputStream(output, getBufferSize()); output = new ToNetASCIIOutputStream(output); } return new org.apache.commons.net.io.SocketOutputStream(socket, output); }
/*** * Writes a byte array to the stream. * <p> * @param buffer The byte array to write. * @exception IOException If an error occurs while writing to the underlying * stream. ***/ public synchronized void write(byte buffer[]) throws IOException { write(buffer, 0, buffer.length); }
private OutputStream __storeFileStream(int command, String remote) throws IOException { OutputStream output; Socket socket; if ((socket = _openDataConnection_(command, remote)) == null) return null; output = socket.getOutputStream(); if (__fileType == ASCII_FILE_TYPE) { // We buffer ascii transfers because the buffering has to // be interposed between ToNetASCIIOutputSream and the underlying // socket output stream. We don't buffer binary transfers // because we don't want to impose a buffering policy on the // programmer if possible. Programmers can decide on their // own if they want to wrap the SocketOutputStream we return // for file types other than ASCII. output = new BufferedOutputStream(output, getBufferSize()); output = new ToNetASCIIOutputStream(output); } return new org.apache.commons.net.io.SocketOutputStream(socket, output); }
/*** * Writes a byte array to the stream. * <p> * @param buffer The byte array to write. * @exception IOException If an error occurs while writing to the underlying * stream. ***/ @Override public synchronized void write(byte buffer[]) throws IOException { write(buffer, 0, buffer.length); }
); if (__fileType == ASCII_FILE_TYPE) output = new ToNetASCIIOutputStream(output);
/*** * Writes a number of bytes from a byte array to the stream starting from * a given offset. * <p> * @param buffer The byte array to write. * @param offset The offset into the array at which to start copying data. * @param length The number of bytes to write. * @exception IOException If an error occurs while writing to the underlying * stream. ***/ public synchronized void write(byte buffer[], int offset, int length) throws IOException { while (length-- > 0) write(buffer[offset++]); }
); if (__fileType == ASCII_FILE_TYPE) output = new ToNetASCIIOutputStream(output);
/*** * Writes a number of bytes from a byte array to the stream starting from * a given offset. * <p> * @param buffer The byte array to write. * @param offset The offset into the array at which to start copying data. * @param length The number of bytes to write. * @exception IOException If an error occurs while writing to the underlying * stream. ***/ @Override public synchronized void write(byte buffer[], int offset, int length) throws IOException { while (length-- > 0) write(buffer[offset++]); }
/*** * Handles special connection requirements. * <p> * @exception IOException If an error occurs during connection setup. ***/ protected void _connectAction_() throws IOException { super._connectAction_(); InputStream input; TelnetInputStream tmp; if (FromNetASCIIInputStream.isConversionRequired()) input = new FromNetASCIIInputStream(_input_); else input = _input_; tmp = new TelnetInputStream(input, this, readerThread); if(readerThread) { tmp._start(); } // __input CANNOT refer to the TelnetInputStream. We run into // blocking problems when some classes use TelnetInputStream, so // we wrap it with a BufferedInputStream which we know is safe. // This blocking behavior requires further investigation, but right // now it looks like classes like InputStreamReader are not implemented // in a safe manner. __input = new BufferedInputStream(tmp); __output = new ToNetASCIIOutputStream(new TelnetOutputStream(this)); }
/*** * Handles special connection requirements. * <p> * @exception IOException If an error occurs during connection setup. ***/ @Override protected void _connectAction_() throws IOException { super._connectAction_(); InputStream input; TelnetInputStream tmp; if (FromNetASCIIInputStream.isConversionRequired()) input = new FromNetASCIIInputStream(_input_); else input = _input_; tmp = new TelnetInputStream(input, this, readerThread); if(readerThread) { tmp._start(); } // __input CANNOT refer to the TelnetInputStream. We run into // blocking problems when some classes use TelnetInputStream, so // we wrap it with a BufferedInputStream which we know is safe. // This blocking behavior requires further investigation, but right // now it looks like classes like InputStreamReader are not implemented // in a safe manner. __input = new BufferedInputStream(tmp); __output = new ToNetASCIIOutputStream(new TelnetOutputStream(this)); }
OutputStream os = new ToNetASCIIOutputStream( client.getOutputStream() );