/** * Set the type of the file transfer. Only Image is supported */ private void setType() throws IOException { write("TYPE I\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to set transfer type"); } }
private void getFile() throws IOException { int reply; String file = url.getFile(); write("RETR " + file + "\r\n"); reply = getReply(); if (reply == FTP_NOTFOUND && file.length() > 0 && file.charAt(0) == '/') { write("RETR " + file.substring(1) + "\r\n"); reply = getReply(); } if (!(reply == FTP_OPENDATA || reply == FTP_TRANSFEROK)) { throw new FileNotFoundException("Unable to retrieve file: " + reply); } }
private void port() throws IOException { write("PORT " + controlSocket.getLocalAddress().getHostAddress().replace('.', ',') + ',' + (dataPort >> 8) + ',' + (dataPort & 255) + "\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to configure data port"); } }
/** * Issue the STOR command to the server with the file as the parameter */ private void sendFile() throws IOException { int reply; write("STOR " + url.getFile().substring(url.getFile().lastIndexOf('/') + 1, url.getFile().length()) + "\r\n"); reply = getReply(); if (!(reply == FTP_OPENDATA || reply == FTP_OK || reply == FTP_DATAOPEN)) { throw new IOException("Unable to store file"); } }
/** * Change the server directory to that specified in the URL */ private void cd() throws IOException { int idx = url.getFile().lastIndexOf('/'); if (idx > 0) { String dir = url.getFile().substring(0, idx); write("CWD " + dir + "\r\n"); int reply = getReply(); if (reply != FTP_FILEOK && dir.length() > 0 && dir.charAt(0) == '/') { write("CWD " + dir.substring(1) + "\r\n"); reply = getReply(); } if (reply != FTP_FILEOK) { throw new IOException("Unable to change directories"); } } }
private void login() throws IOException { int reply; reply = getReply(); if (reply == FTP_USERREADY) { } else { throw new IOException("Unable to connect to server: " + url.getHost()); } write("USER " + username + "\r\n"); reply = getReply(); if (reply == FTP_PASWD || reply == FTP_LOGGEDIN) { } else { throw new IOException("Unable to log in to server (USER): " + url.getHost()); } if (reply == FTP_PASWD) { write("PASS " + password + "\r\n"); reply = getReply(); if (!(reply == FTP_OK || reply == FTP_USERREADY || reply == FTP_LOGGEDIN)) { throw new IOException("Unable to log in to server (PASS): " + url.getHost()); } } }
private void port() throws IOException { write("PORT " + controlSocket.getLocalAddress().getHostAddress().replace('.', ',') + ',' + (dataPort >> 8) + ',' + (dataPort & 255) + "\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to configure data port"); } }
/** * Set the type of the file transfer. Only Image is supported */ private void setType() throws IOException { write("TYPE I\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to set transfer type"); } }
/** * Issue the STOR command to the server with the file as the parameter */ private void sendFile() throws IOException { int reply; write("STOR " + url.getFile().substring(url.getFile().lastIndexOf('/') + 1, url.getFile().length()) + "\r\n"); reply = getReply(); if (!(reply == FTP_OPENDATA || reply == FTP_OK || reply == FTP_DATAOPEN)) { throw new IOException("Unable to store file"); } }
/** * Set the type of the file transfer. Only Image is supported */ private void setType() throws IOException { write("TYPE I\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to set transfer type"); } }
private void port() throws IOException { write("PORT " + controlSocket.getLocalAddress().getHostAddress().replace('.', ',') + ',' + (dataPort >> 8) + ',' + (dataPort & 255) + "\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to configure data port"); } }
/** * Issue the STOR command to the server with the file as the parameter */ private void sendFile() throws IOException { int reply; write("STOR " + url.getFile().substring(url.getFile().lastIndexOf('/') + 1, url.getFile().length()) + "\r\n"); reply = getReply(); if (!(reply == FTP_OPENDATA || reply == FTP_OK || reply == FTP_DATAOPEN)) { throw new IOException("Unable to store file"); } }
private void getFile() throws IOException { int reply; String file = url.getFile(); write("RETR " + file + "\r\n"); reply = getReply(); if (reply == FTP_NOTFOUND && file.length() > 0 && file.charAt(0) == '/') { write("RETR " + file.substring(1) + "\r\n"); reply = getReply(); } if (!(reply == FTP_OPENDATA || reply == FTP_TRANSFEROK)) { throw new FileNotFoundException("Unable to retrieve file: " + reply); } }
/** * Issue the STOR command to the server with the file as the parameter */ private void sendFile() throws IOException { int reply; write("STOR " + url.getFile().substring(url.getFile().lastIndexOf('/') + 1, url.getFile().length()) + "\r\n"); reply = getReply(); if (!(reply == FTP_OPENDATA || reply == FTP_OK || reply == FTP_DATAOPEN)) { throw new IOException("Unable to store file"); } }
/** * Set the type of the file transfer. Only Image is supported */ private void setType() throws IOException { write("TYPE I\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to set transfer type"); } }
private void port() throws IOException { write("PORT " + controlSocket.getLocalAddress().getHostAddress().replace('.', ',') + ',' + (dataPort >> 8) + ',' + (dataPort & 255) + "\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to configure data port"); } }
/** * Issue the STOR command to the server with the file as the parameter */ private void sendFile() throws IOException { int reply; write("STOR " + url.getFile().substring(url.getFile().lastIndexOf('/') + 1, url.getFile().length()) + "\r\n"); reply = getReply(); if (!(reply == FTP_OPENDATA || reply == FTP_OK || reply == FTP_DATAOPEN)) { throw new IOException("Unable to store file"); } }
private void port() throws IOException { write("PORT " + controlSocket.getLocalAddress().getHostAddress().replace('.', ',') + ',' + (dataPort >> 8) + ',' + (dataPort & 255) + "\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to configure data port"); } }
/** * Set the type of the file transfer. Only Image is supported */ private void setType() throws IOException { write("TYPE I\r\n"); if (getReply() != FTP_OK) { throw new IOException("Unable to set transfer type"); } }
private void getFile() throws IOException { int reply; String file = url.getFile(); write("RETR " + file + "\r\n"); reply = getReply(); if (reply == FTP_NOTFOUND && file.length() > 0 && file.charAt(0) == '/') { write("RETR " + file.substring(1) + "\r\n"); reply = getReply(); } if (!(reply == FTP_OPENDATA || reply == FTP_TRANSFEROK)) { throw new FileNotFoundException("Unable to retrieve file: " + reply); } }