请高手赐教!版主帮我顶啊!谢谢!
本段程序是实现按照本地机器上的一个文件夹目录结构传送到FTP服务器上的功能,为了简化方便高手的解答我只传送一层,多层跟这个一样的问题!下面程序中一个是判断文件和文件夹的,两个相互分开时,可以运行,但放在一起会出错!
错误信息:
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: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:118)
sun.net.ftp.Ftp
ProtocolException: 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:118)
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:118)
源程序是:
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);
int i=count-1;
while(i> =0)