final String message = __buildMessage(command, args); __send(message); fireCommandSent(command, message); __getReply(); return _replyCode;
/** * Initiates control connections and gets initial reply. * Initializes {@link #_controlInput_} and {@link #_controlOutput_}. */ @Override protected void _connectAction_() throws IOException { _connectAction_(null); }
/** * Closes the connection to the FTP server and restores * connection parameters to the default values. * * @throws IOException If an error occurs while disconnecting. */ @Override public void disconnect() throws IOException { super.disconnect(); __initDefaults(); }
/** * @param file name of file * @return the status * @throws IOException on error * @since 2.0 **/ public int mdtm(String file) throws IOException { return sendCommand(FTPCmd.MDTM, file); }
while ( isStrictMultilineParsing() ? __strictCheck(line, code) : __lenientCheck(line)); } else if (isStrictReplyParsing()) { if (length == REPLY_CODE_LEN + 1) { // expecting some text throw new MalformedServerReplyException("Truncated server reply: '" + line +"'"); } else if (isStrictReplyParsing()) { throw new MalformedServerReplyException("Truncated server reply: '" + line +"'"); fireReplyReceived(_replyCode, getReplyString());
if (!isConnected() || !socketIsConnected(_socket_)) _commandSupport_.fireCommandSent(command, message); __getReply(); return _replyCode;
while ( isStrictMultilineParsing() ? __strictCheck(line, code) : __lenientCheck(line)); _commandSupport_.fireReplyReceived(_replyCode, getReplyString());
if(socketIsReader == null) { _controlInput_ = new CRLFLineReader(new InputStreamReader(_input_, getControlEncoding())); } else { _controlInput_ = new CRLFLineReader(socketIsReader); new BufferedWriter(new OutputStreamWriter(_output_, getControlEncoding())); if (connectTimeout > 0) { // NET-385 int original = _socket_.getSoTimeout(); _socket_.setSoTimeout(connectTimeout); try { __getReply(); __getReply(); __getReply(); __getReply();
protected void _connectAction_() throws IOException { super._connectAction_(); _controlInput = new BufferedReader(new InputStreamReader(getInputStream(), getControlEncoding())); _controlOutput = new BufferedWriter(new OutputStreamWriter(getOutputStream(), getControlEncoding())); __getReply(); // If we received code 120, we have to fetch completion reply. if (FTPReply.isPositivePreliminary(_replyCode)) __getReply(); }
/** * Get the reply, but don't pass it to command listeners. * Used for keep-alive processing only. * @since 3.0 * @throws IOException on error */ protected void __getReplyNoReport() throws IOException { __getReply(false); }
/*** * The default FTP constructor. Sets the default port to * <code>DEFAULT_PORT</code> and initializes internal data structures * for saving FTP reply information. ***/ public FTP() { super(); setDefaultPort(DEFAULT_PORT); _replyLines = new ArrayList<String>(); _newReplyString = false; _replyString = null; _controlEncoding = DEFAULT_CONTROL_ENCODING; _commandSupport_ = new ProtocolCommandSupport(this); }
private void __send(String message) throws IOException, FTPConnectionClosedException, SocketException { try{ _controlOutput_.write(message); _controlOutput_.flush(); } catch (SocketException e) { if (!isConnected()) { throw new FTPConnectionClosedException("Connection unexpectedly closed."); } else { throw e; } } }
_commandSupport_.fireReplyReceived(_replyCode, getReplyString());
/** * A convenience method to send the FTP FEAT command to the server, receive the reply, * and return the reply code. * @return The reply code received by the server * @throws IOException If an I/O error occurs while either sending the * command or receiving the server reply. * @since 2.2 */ public int feat() throws IOException { return sendCommand(FTPCmd.FEAT); }
if (!isConnected() || !socketIsConnected(_socket_)) _commandSupport_.fireCommandSent(command, message); __getReply(); return _replyCode;
/** * Initiates control connections and gets initial reply. * Initializes {@link #_controlInput_} and {@link #_controlOutput_}. */ @Override protected void _connectAction_() throws IOException { super._connectAction_(); _controlInput_ = new BufferedReader(new InputStreamReader(_socket_.getInputStream(), getControlEncoding())); _controlOutput_ = new BufferedWriter(new OutputStreamWriter(_socket_.getOutputStream(), getControlEncoding())); __getReply(); // If we received code 120, we have to fetch completion reply. if (FTPReply.isPositivePreliminary(_replyCode)) __getReply(); }
/** * Get the reply, and pass it to command listeners */ private void __getReply() throws IOException { __getReply(true); }
/*** * The default FTP constructor. Sets the default port to * <code>DEFAULT_PORT</code> and initializes internal data structures * for saving FTP reply information. ***/ public FTP() { setDefaultPort(DEFAULT_PORT); __commandBuffer = new StringBuffer(); _replyLines = new Vector(); _newReplyString = false; _replyString = null; _commandSupport_ = new ProtocolCommandSupport(this); _controlEncoding = DEFAULT_CONTROL_ENCODING; }
/** * A convenience method to send the FTP PASS command to the server, * receive the reply, and return the reply code. * @param password The plain text password of the username being logged into. * @return The reply code received from the server. * @throws FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @throws IOException If an I/O error occurs while either sending the * command or receiving the server reply. */ public int pass(String password) throws IOException { return sendCommand(FTPCmd.PASS, password); }
/*** * Fetches a reply from the FTP server and returns the integer reply * code. After calling this method, the actual reply text can be accessed * from either calling {@link #getReplyString getReplyString } or * {@link #getReplyStrings getReplyStrings }. Only use this * method if you are implementing your own FTP client or if you need to * fetch a secondary response from the FTP server. * * @return The integer value of the reply code of the fetched FTP reply. * @throws FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @throws IOException If an I/O error occurs while receiving the * server reply. ***/ public int getReply() throws IOException { __getReply(); return _replyCode; }