2012-06-27 2 views
1

내가 FTPClient를 통해 FTP 서버에 파일을 보내려고 노력했지만 그것은 말한다 :는 FTPClient 열 수 없습니다 파일은, 그런 파일이나 디렉토리

553 수 ' t 파일 열기 : 해당 파일이나 디렉토리가 없습니다. 내가 답을 인터넷을 통해 모든보고 된 적이 있지만 아무 일 없다

try 
{ 
    FTPClient client = new FTPClient(); 
    client.connect(hostname); 
    client.login(username, password); 

    client.setFileType(FTP.BINARY_FILE_TYPE); 
    client.enterLocalPassiveMode(); 
    client.changeWorkingDirectory(workingDir);   
    File dir = new File(savePath + fileName); 
    FileInputStream fIS = new FileInputStream(dir); 

    for(File files : dir.listFiles()) 
    { 
     boolean success = client.storeFile(files.getPath(), fIS); 
     Toast.makeText(getBaseContext(), client.getReplyString(), Toast.LENGTH_LONG).show(); 
     Toast.makeText(getBaseContext(), files.getPath() + " Stored = " + success, Toast.LENGTH_LONG).show(); 
    } 

    fIS.close(); 
    client.logout(); 
} 
catch (SocketException e) 
{ 
    Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show(); 
} 
catch (IOException e) 
{ 
    Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show(); 
} 

: 여기

는 코드입니다.

+0

이제는 "IOException : 복사하는 동안 잡혔습니다."라는 메시지가 나타납니다. 어떤 아이디어? – kamden

+0

대답은 for 루프 내부에서 FileInputStream을 이동하는 것이 었습니다. 이제 파일이 전송되었지만 여전히 FTP 서버에는 없습니다. 나는 그것을 얻지 않는다 – kamden

+0

나의 나쁜, FileZilla는 다만 재 장전하는 것이 천천히, 파일은 거기있다있다 – kamden

답변

1

CoolBeans의 도움으로 문제가 해결되었습니다.

client.storeFile(files.getPath(), fIS); 

에 :

비슷한 문제를 가진 사람을위한 솔루션은

1.Change는 IS

client.storeFile(files.getName(), fIS); 

그리고에 대한 루프로 FileInputStream의 이동과로 변경 :

new FileInputStream(files); 
관련 문제