Seem that I can not get a directory listing when the path has a space in it. This is only when using pureFTP server (
www.pure-ftpd.org ) Here is a sample JSP that I have been using.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="com.enterprisedt.net.ftp.*"%>
<%
String host = "192.168.1.51";
String username = "root";
String password = "XXXXXXX";
FTPClient ftp = null;
try {
// create client
System.out.println("Creating FTP client");
ftp = new FTPClient();
// set remote host
System.out.println("Setting remote host");
ftp.setRemoteHost(host);
// connect to the server
System.out.println("Connecting to server " + host);
ftp.connect();
System.out.println("Connected to server " + host);
// log in
System.out.println("Logging in with username=" + username + " and password=" + password);
ftp.login(username, password);
System.out.println("Logged in");
// Test Here
String[] files = ftp.dir( "/root/test directory", true );
for (int i = 0; i < files.length; i++) {
System.out.println(files[i].toString());
}
// Shut down client
System.out.println("Quitting client");
ftp.quit();
System.out.println("Example complete");
} catch (Exception e) {
e.printStackTrace();
}
%>