这个问题是往FTP上传文件,把本地机上的一个文件夹的内容按照文件夹的目录结构传到FTP上,问题是:一个上判断是否为文件夹的if(filelist[i].isDirectory()==true)和else,else中的内容是往FTP上写文件,
出现以下报错;但是要是把if或else其中的一个屏蔽掉一个,完全可以执行其中的内容!下面源程序只是实现一层文件夹的上传,多层的与这个一样的错误!有朋友回答过这个问题,但是没答出解决方法,希望有朋友帮帮我,真的很急,谢谢!
java.io.FileNotFoundException: CWD /2: 550 /2/???¨??????: Failed to create.
at sun.net.ftp.FtpClient.readReply(Unknown Source)
at sun.net.ftp.FtpClient.issueCommand(Unknown Source)
at sun.net.ftp.FtpClient.issueCommandCheck(Unknown Source)
at sun.net.ftp.FtpClient.cd(Unknown Source)
at shareit.ftp.FtpConnection.run(FTPtxt.java:106)
sun.net.ftp.FtpProtocolException: PORT :500 'EPRT ': command not understood.
at sun.net.ftp.FtpClient.openDataConnection(Unknown Source)
at sun.net.ftp.FtpClient.put(Unknown Source)
at shareit.ftp.FtpConnection.run(FTPtxt.java:110)
sun.net.ftp.FtpProtocolException: PORT :500 'EPRT ': command not understood.
at sun.net.ftp.FtpClient.openDataConnection(Unknown Source)
at sun.net.ftp.FtpClient.put(Unknown Source)
at shareit.ftp.FtpConnection.run(FTPtxt.java:110)
sun.net.ftp.FtpProtocolException: PORT :500 'EPRT ': command not understood.
at sun.net.ftp.FtpClient.openDataConnection(Unknown Source)
at sun.net.ftp.FtpClient.put(Unknown Source)
at shareit.ftp.FtpConnection.run(FTPtxt.java:110)
源程序如下:
package shareit.ftp;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import sun.net.TelnetOutputStream;
import sun.net.ftp.FtpClient;
class Node
{
File[] fle;
}
class FtpConnection extends Thread
{ //private String user;
//private String password;
private FtpClient ftpclient;
FtpConnection()
{
try{ftpclient=new FtpClient( "192.168.0.66 ",21);
Login();
}
catch(Exception e){}
}
public void Login()
{
try {
ftpclient.login( "winterzd ", "2251780 ");
} catch (IOException e) {
e.printStackTrace();
}
}
public void Logout()
{
ftpclient.sendServer( "QUIT\r\n ");
int reply = 0;
try {
reply = ftpclient.readServerResponse();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(reply);
}
public void run()
{
try {
//readirt();
//*********************************************
File file=new File( "D:\\2 ");
File[] filelist=file.listFiles();
int count=filelist.length;
//System.out.println(count);