是否可以通过时间戳使用Apache ftp客户端和列出目录内容? 我在做:
mFtpClient.listNames("-t .");
但是返回一个空列表。
编辑:我正在使用Filezilla Server。
答案 0 :(得分:0)
我已经用这种方式解决了:
public class CustomFTPClient extends FTPClient{
public String[] listNamesOrdered(String pathname) throws IOException
{
if(pathname == null) pathname = "";
StringBuilder sb = new StringBuilder(pathname.length() + 3);
sb.append("-t -A1 ");
sb.append(pathname);
pathname = sb.toString();
Socket socket = _openDataConnection_(FTPCmd.LIST, getListArguments(pathname));
if (socket == null) {
return null;
}
BufferedReader reader =
new BufferedReader(new InputStreamReader(socket.getInputStream(), getControlEncoding()));
ArrayList<String> results = new ArrayList<String>();
String line;
while ((line = reader.readLine()) != null) {
results.add(line);
}
reader.close();
socket.close();
if (completePendingCommand())
{
String[] names = new String[ results.size() ];
return results.toArray(names);
}
return null;
}
}
我复制了listNames方法,并使用带-t参数的LIST命令。