2014-06-19 2 views
1

appss commons 메서드를 사용하여 FTP 서버에서 일부 파일을 다운로드하고 zip 파일이 손상되는 문제가 있습니다. 파일을 다운로드하고 올바른 폴더에 파일을 넣을 수는 있지만 열 때 파일이 누락되어 정상적인 .txt 파일로 다운로드하려고하면 파일이 손상되었다고 주장합니다.java downloading zip 파일이 손상되었습니다.

public boolean downloadFiles(String folder, String file) throws Exception 
{ 
    File output = new File(folder + "\\" + file); 
    System.out.println(output); 
    FileOutputStream out = new FileOutputStream(output); 
    client.retrieveFile(file, out); 
    out.close(); 

    if(output.exists())  
     return true; 
    else 
     return false; 

} 
+0

참조 http://stackoverflow.com/questions/1601872/corrupt-image-file-after-uploading-it-using-ftp-command-from-linux-with-type-as – Raedwald

+0

http :// /stackoverflow.com/questions/6155905/in-what-situation-should-i-using-ascii-to-transfer-a-file-over-ftp-im-not-askin – Raedwald

+0

참고 사항 [FTPClient - Java, 파일 업로드 ] (http://stackoverflow.com/questions/5925572/ftpclient-java-upload-file) – Raedwald

답변

3

FTP 전송에 바이너리 모드를 사용해야합니다. txt 파일이 작동한다는 사실은이 문제가 가장 가능성이 높음을 나타냅니다.

+0

지금 시도해보십시오. – joe

+0

대단히 감사합니다! – joe

1

Java 클라이언트에서 다운로드하는 파일은 수동으로 FTP 위치로 이동하여보십시오. zip 파일이 괜찮은지 확인하십시오. 나는 비슷한 문제가 있었고 zip 파일이 손상되었음을 알았습니다. 두 번째 단계는 다운로드하는 zip 파일의 크기와 다운로드 한 파일의 크기를 확인하는 것입니다.

+0

그래, 클라이언트에서 파일을 다운로드 할 수 있고 손상되지 않았습니다. 프로그램에서 다운로드 한 파일 크기는 실제로 클라이언트에서 다운로드 할 때보 다 크다. o.o – joe

+0

retrieveFile (..) 메소드의 paste impl. – ppuskar

관련 문제