问题描述
- java socket 实现ftp服务器 list命令 返回数据格式
-
boolean commandLIST()
{
try
{
dsocket = new Socket(remoteHost,remotePort,InetAddress.getLocalHost(),20);
PrintWriter dout = new PrintWriter(dsocket.getOutputStream(),true);
if(param.equals("") || param.equals("LIST"))
{
out.println("150 Opening ASCII mode data connection for /bin/ls. ");
File f = new File(dir);
String[] dirStructure = f.list();
String fileType;
for(int i =0; i<dirStructure.length;i++)
{
if(dirStructure[i].indexOf(".")!=-1)
{
fileType = "- ";
}
else
{
fileType = "d ";
}
out.println(f.listFiles());
}
}
else
{} dout.close(); dsocket.close(); reply = "226 Transfer complete !"; } catch(Exception e) { e.printStackTrace(); reply = "451 Requested action aborted: local error in processing"; return false; } return false; }
客户端使用Apache 的 ftpclient listfiles方法,接收后提示
org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
Server Reply: - testb.txt(这是目录下第一个文件名)怎么解决啊
时间: 2024-09-20 22:47:00