commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 34778] - [net] FTP CWD command seems not to trigger server responses properly
Date Wed, 30 Aug 2006 14:39:55 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34778>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34778


rwinston@eircom.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID




------- Additional Comments From rwinston@eircom.net  2006-08-30 14:39 -------
I think the problem here may be that you are not calling
completePendingCommand().   The call to pwd() executed internally by FTPClient
does not retrieve the correct return code otherwise, and returns null. Here is
an example:

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();

If you comment out the call to completePendingCommand() above, it will print
"null" for the directory name.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message