Discuss (FTP) and (SFTP, FTPS and SCP), our Java file transfer clients.
no avatar
User

rthomas@stone-ware.com

Posts

3

Joined

Fri Sep 05, 2008 12:52 am

Problems with spaces and pure-ftp

by rthomas@stone-ware.com » Fri Sep 05, 2008 12:56 am

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();
}
%>
Last edited by rthomas@stone-ware.com on Thu Sep 18, 2008 1:46 am, edited 1 time in total.
no avatar
User

rthomas@stone-ware.com

Posts

3

Joined

Fri Sep 05, 2008 12:52 am

by rthomas@stone-ware.com » Fri Sep 05, 2008 1:02 am

dir() and dir(java.lang.String dirname) both work. dir(java.lang.String dirname, boolean full) does not.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Tue Sep 09, 2008 7:26 am

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.
no avatar
User

rthomas@stone-ware.com

Posts

3

Joined

Fri Sep 05, 2008 12:52 am

by rthomas@stone-ware.com » Thu Sep 18, 2008 1:47 am


Who is online

Users browsing this forum: No registered users and 18 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign