commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jesper Carlsson" <jca...@gmail.com>
Subject Re:[commons-net] FTP – missing folder / directory
Date Tue, 22 Aug 2006 12:14:48 GMT
Updated and corrected info: When calling FTPClient.listFiles() I get
FTPFile[] with length 50. Of this 50 array elements there is one
element that is null, and this is where the missing directory should
be. I am able to enter the directory with
FTPClient.changeWorkingDirectory() (I can do this because I know the
name of the directory).

My new test code (I call test() from main()):

public static void test() {
	try {
		FTPClient client = new FTPClient();
		client.connect("<host>");
		System.out.println("Reply: " + client.getReplyString());

		// After connection attempt, you should check the reply code to
verify success.
		if(!FTPReply.isPositiveCompletion(client.getReplyCode())) {
			throw new IOException("FTP server refused connection.");
		}

		client.login("<user>", "<pass>");
		System.out.println("Reply: " + client.getReplyString());

		test2(client, "it");
		System.out.println();
		test2(client, "itseelmax0018");
		System.out.println();
		test2(client, "ebccoms01-7.7.0-01");

		System.out.println("Status: " + client.getStatus());
	} catch (IOException e) {
		e.printStackTrace();
	}
}
public static void test2(FTPClient client, String dir) throws IOException {
	boolean changeDir = client.changeWorkingDirectory(dir);
	System.out.println("Changed to " + dir + ": " + changeDir);
	System.out.println("ReplyString: " + client.getReplyString());
	System.out.println("rs.length: " + client.getReplyStrings().length);
	FTPFile[] f = client.listFiles();
	System.out.println("ReplyString: " + client.getReplyString());
	System.out.println("rs.length: " + client.getReplyStrings().length);
	System.out.println("list.length: " + f.length);
	for (int i = 0; i < f.length; i++) {
		System.out.println((f[i] != null ? f[i].getName() : "null"));
	}
}

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


Mime
View raw message