java.lang.Objectjava.io.OutputStream
cz.dhl.ftp.FtpOutputStream
Allows writing into FTP file.
Ftp,
FtpFile| Constructor Summary | |
FtpOutputStream(FtpFile file)
Opens 'store' OutputStream for given filename. |
|
FtpOutputStream(FtpFile file,
boolean append)
Open either 'store' or 'append' OutputStream for given filename. |
|
FtpOutputStream(FtpFile file,
FtpConnect connect,
CoConsole console)
Opens 'store' concurent OutputStream for given filename. |
|
FtpOutputStream(FtpFile file,
FtpConnect connect,
CoConsole console,
boolean append)
Open either 'store' or 'append' concurent OutputStream for given filename. |
|
| Method Summary | |
void |
close()
Close current data transfer and close data connection. |
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out. |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array
to this output stream. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this output stream.
|
void |
write(int b)
Writes the specified byte to this output stream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FtpOutputStream(FtpFile file)
throws java.io.IOException
This constructor behaves similarly to
.FtpOutputStream(FtpFile,boolean)
file - the file to be opened for writing
java.io.IOException - socket error
public FtpOutputStream(FtpFile file,
boolean append)
throws java.io.IOException
STOR - store
This command causes the server-DTP to accept the data transferred via the data connection and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist.
APPE - append (with create)
This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site.
file - the file to be opened for writingappend - if true, then bytes will be written to the
end of the file rather than the beginning
java.io.IOException - socket error
public FtpOutputStream(FtpFile file,
FtpConnect connect,
CoConsole console)
throws java.io.IOException
This constructor behaves similarly to
.FtpOutputStream(FtpFile,FtpConnect,CoConsole,boolean)
file - the file to be opened for writingconnect - login detailsconsole - message output
java.io.IOException - socket error
public FtpOutputStream(FtpFile file,
FtpConnect connect,
CoConsole console,
boolean append)
throws java.io.IOException
Single ftp connection cannot handle multiple concurent data transfers. This limitation can be eliminated by creating new ftp connection for each concurent data transfer. This constructor creates separate Ftp instance.
Note (1) supplying same CoConsole instance for multiple sessions will produce messed output.
Note (2) This code may need to be run in separate thread to process multiple files concurently.
STOR - store
This command causes the server-DTP to accept the data transferred via the data connection and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist.
APPE - append (with create)
This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site.
file - the file to be opened for writingconnect - login detailsconsole - message outputappend - if true, then bytes will be written to the
end of the file rather than the beginning
java.io.IOException - socket errorFtpOutputStream(FtpFile,boolean)| Method Detail |
public void close()
throws java.io.IOException
If no reply ABOR - abort
This command tells the server to abort the previous FTP service command and any associated transfer of data. No action is to be taken if the previous command has been completed (including data transfer). The control connection is not to be closed by the server, but the data connection must be closed. There are two cases for the server upon receipt of this command:
(1) the FTP service command was already completed. The server closes the data connection (if it is open) and responds with a 226 reply, indicating that the abort command was successfully processed.
(2) the FTP service command is still in progress. The server aborts the FTP service in progress and closes the data connection, returning a 426 reply to indicate that the service request terminated abnormally. The server then sends a 226 reply, indicating that the abort command was successfully processed.
java.io.IOException - socket error
public void flush()
throws java.io.IOException
flush is
that calling it is an indication that, if any bytes previously
written have been buffered by the implementation of the output
stream, such bytes should immediately be written to their
intended destination.
java.io.IOException - if an I/O error occurs.
public void write(byte[] b)
throws java.io.IOException
b.length bytes from the specified byte array
to this output stream. The general contract for write(b)
is that it should have exactly the same effect as the call
write(b, 0, b.length).
b - the data.
java.io.IOException - if an I/O error occurs.write(byte[], int, int)
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes from the specified byte array
starting at offset off to this output stream.
The general contract for write(b, off, len) is that
some of the bytes in the array b are written to the
output stream in order; element b[off] is the first
byte written and b[off+len-1] is the last byte written
by this operation.
The write method of OutputStream calls
the write method of one argument on each of the bytes to be
written out. Subclasses are encouraged to override this method and
provide a more efficient implementation.
If b is null, a
NullPointerException is thrown.
If off is negative, or len is negative, or
off+len is greater than the length of the array
b, then an IndexOutOfBoundsException is thrown.
b - the data.off - the start offset in the data.len - the number of bytes to write.
java.io.IOException - if an I/O error occurs. In particular,
an IOException is thrown if the output
stream is closed.
public void write(int b)
throws java.io.IOException
write is that one byte is written
to the output stream. The byte to be written is the eight
low-order bits of the argument b. The 24
high-order bits of b are ignored.
b - the byte.
java.io.IOException - if an I/O error occurs. In particular,
an IOException may be thrown if the
output stream has been closed.