2013-02-16 2 views
0

내가 (A zip 파일 내가 FTP를 통해 그를 추출하기 위해 애 쓰고 server.so에) 서버에서 zip 파일을 추출하려고 내가이 코드를 사용하고,FTP zip 파일 추출 오류

byte[] buf = new byte[1024]; 

    ZipInputStream zinstream = new ZipInputStream(Home.ftpClient.retrieveFileStream("HO2BR.br.3162675983055490721.zync")); 
    ZipEntry zentry = zinstream.getNextEntry(); 
    System.out.println("Name of current Zip Entry : " + zentry + "\n"); 
    while (zentry != null) { 
     String entryName = zentry.getName(); 
     System.out.println("Name of Zip Entry : " + entryName); 
     FileOutputStream outstream = new FileOutputStream(entryName); 
     int n; 

     while ((n = zinstream.read(buf, 0, 1024)) > -1) { 
      outstream.write(buf, 0, n); 

     } 
     System.out.println("Successfully Extracted File Name : " + entryName); 
     outstream.close(); 

     zinstream.closeEntry(); 
     zentry = zinstream.getNextEntry(); 
    } 
    zinstream.close(); 

} 

ZipInputStream (Home.ftpClient.retrieveFileStream ("HO2BR.br.3162675983055490721.zync"))); 이 오류는

java.util.zip.ZipException 발생하는 프로그램이 실행되는 동안 입력 스트림FTPClient의 retrieveFileStream에게

할당 잘못된 거리를 너무 거슬러 java.util.zip에서. InflaterInputStream.read (InflaterInputStream.java:164)

이 예외는 어떻게 해결할 수 있습니까?

답변

2

대부분 ftpClient.retrieveFileStream은 검색을 지원하지 않습니다. Zip "목차"항목은 파일의 맨 끝에 나옵니다. 따라서 첫 번째 항목을 "열기"위해서는 해당 항목을 읽기 위해 파일의 시작 부분까지 백업 할 수 있어야합니다.

zip 파일을 로컬 파일로 다운로드 한 다음 해당 파일의 압축을 풀어야합니다.

+0

안녕하세요, 서버에서 압축 파일을 추출 할 수 있습니다. 파일을 다운로드하지 않고 서버에 압축을 풀어야합니다. –

관련 문제