Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.5k views
in Java FTP by (200 points)
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();
}
%>

3 Answers

0 votes
by (200 points)
dir() and dir(java.lang.String dirname) both work. dir(java.lang.String dirname, boolean full) does not.
0 votes
by (162k points)
In cases like this one approach is to change into the directory you are listing and then call dir("", true).

If this doesn't work please email us a log file at the DEBUG level.
0 votes
by (200 points)
This has resovled our problem. Thanks

Categories

...