Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" for change notification.
The following page has been changed by RoryWinston: http://wiki.apache.org/jakarta-commons/Net/FrequentlyAskedQuestions ------------------------------------------------------------------------------ enterLocalPassiveMode(); } }}} + Also see [http://cephas.net/blog/2004/05/27/commons-net-ftp-and-active-vs-pasv-connections/] ---- '''Q: Using the NNTPClient, retrieving a list of headers takes forever. Why is that?''' @@ -135, +136 @@ threads, you must serialize access to the object with critical sections. ---- - '''Q: Does the SMTP client support ESMTP functions? Does it support RFC2821, RFC2822, RFC2487 TLS, RFC2554 authentication, RFC2920 command pipelining, RFC3030 large/binary messages, etc.?''' - ---- '''Q: Does FTPClient support FTP connections through an FTP proxy server?''' '''A:''' Paul Buchanan answers this question here: http://marc.theaimsgroup.com/?l=jakarta-commons-user&m=107877944806547&w=2 @@ -203, +202 @@ } catch (Exception e) { ... } }}} - This snipet is a simple version of retrieveFile method. If you consult the original version, you will see that all you need to do is change the copyStream method according to your needs. + This snippet is a simple version of retrieveFile method. If you consult the original version, you will see that all you need to do is change the copyStream method according to your needs. + ---- + '''Q:After I perform a file transfer to the server, printWorkingDirectory() returns null.''' + '''A:'''You need to call `completePendingCommand()` after transferring the file. See the following snippet for a guide: + + {{{ + FTPClient client = new FTPClient(); + client.addProtocolCommandListener(new PrintCommandListener(new + PrintWriter(System.out))); + + client.connect("127.0.0.1"); + client.login("rory", "rory"); + + for (FTPFile file : client.listFiles()) { + System.out.printf("%s %s [%d bytes]\n" ,(file.isDirectory() ? "[D]" : " "), + file.getName(), file.getSize()); + } + + client.enterLocalPassiveMode(); + client.setFileType(FTPClient.BINARY_FILE_TYPE); + client.retrieveFile("A.pdf", new FileOutputStream("c:\\temp\\A.pdf")); + + // Upload a file + InputStream fis = new FileInputStream("c:\\temp\\B.pdf"); + OutputStream os = client.storeFileStream("B.pdf"); + + byte buf[] = new byte[8192]; + while (fis.read(buf) != -1) { + os.write(buf); + } + fis.close(); + os.close(); + client.completePendingCommand(); + + client.changeWorkingDirectory("Dir1"); + for (FTPFile file : client.listFiles()) { + System.out.printf("%s %s [%d bytes]\n" ,(file.isDirectory() ? "[D]" : " "), + file.getName(), file.getSize()); + } + + System.out.println(client.printWorkingDirectory()); + + client.changeToParentDirectory(); + client.changeWorkingDirectory("/D2"); + System.out.println(client.printWorkingDirectory()); + + client.logout(); + client.disconnect(); + }}} + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]