< prev index next >

src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java

Print this page




1194      *        transfer. This must be a value greater than or equal to zero.
1195      * @throws IllegalArgumentException if the offset is negative.
1196      */
1197     public sun.net.ftp.FtpClient setRestartOffset(long offset) {
1198         if (offset < 0) {
1199             throw new IllegalArgumentException("offset can't be negative");
1200         }
1201         restartOffset = offset;
1202         return this;
1203     }
1204 
1205     /**
1206      * Retrieves a file from the ftp server and writes it to the specified
1207      * <code>OutputStream</code>.
1208      * If the restart offset was set, then a <code>REST</code> command will be
1209      * sent before the RETR in order to restart the tranfer from the specified
1210      * offset.
1211      * The <code>OutputStream</code> is not closed by this method at the end
1212      * of the transfer.
1213      *
1214      * @param name a <code>String<code> containing the name of the file to
1215      *        retreive from the server.
1216      * @param local the <code>OutputStream</code> the file should be written to.
1217      * @throws IOException if the transfer fails.
1218      */
1219     public sun.net.ftp.FtpClient getFile(String name, OutputStream local) throws sun.net.ftp.FtpProtocolException, IOException {
1220         int mtu = 1500;
1221         if (restartOffset > 0) {
1222             Socket s;
1223             try {
1224                 s = openDataConnection("REST " + restartOffset);
1225             } finally {
1226                 restartOffset = 0;
1227             }
1228             issueCommandCheck("RETR " + name);
1229             getTransferSize();
1230             InputStream remote = createInputStream(s.getInputStream());
1231             byte[] buf = new byte[mtu * 10];
1232             int l;
1233             while ((l = remote.read(buf)) >= 0) {
1234                 if (l > 0) {




1194      *        transfer. This must be a value greater than or equal to zero.
1195      * @throws IllegalArgumentException if the offset is negative.
1196      */
1197     public sun.net.ftp.FtpClient setRestartOffset(long offset) {
1198         if (offset < 0) {
1199             throw new IllegalArgumentException("offset can't be negative");
1200         }
1201         restartOffset = offset;
1202         return this;
1203     }
1204 
1205     /**
1206      * Retrieves a file from the ftp server and writes it to the specified
1207      * <code>OutputStream</code>.
1208      * If the restart offset was set, then a <code>REST</code> command will be
1209      * sent before the RETR in order to restart the tranfer from the specified
1210      * offset.
1211      * The <code>OutputStream</code> is not closed by this method at the end
1212      * of the transfer.
1213      *
1214      * @param name a {@code String} containing the name of the file to
1215      *        retreive from the server.
1216      * @param local the <code>OutputStream</code> the file should be written to.
1217      * @throws IOException if the transfer fails.
1218      */
1219     public sun.net.ftp.FtpClient getFile(String name, OutputStream local) throws sun.net.ftp.FtpProtocolException, IOException {
1220         int mtu = 1500;
1221         if (restartOffset > 0) {
1222             Socket s;
1223             try {
1224                 s = openDataConnection("REST " + restartOffset);
1225             } finally {
1226                 restartOffset = 0;
1227             }
1228             issueCommandCheck("RETR " + name);
1229             getTransferSize();
1230             InputStream remote = createInputStream(s.getInputStream());
1231             byte[] buf = new byte[mtu * 10];
1232             int l;
1233             while ((l = remote.read(buf)) >= 0) {
1234                 if (l > 0) {


< prev index next >