2011-05-12 10 views
0

다음 코드를 사용하여 파일을 압축 해제합니다.ZIpFile로 파일 압축 해제

"unZip() = java.io.IOException"예외를 catch하고 있지만 파일의 압축이 풀리고 생성되었습니다!

아이디어가 있으십니까?

감사합니다.

public boolean unZipPage(int page) 
{ 
    try 

    { 

    File f=new File(zippagename); 

    FileOutputStream out = new FileOutputStream(f); 

    ZipEntry fh=fhs.get(page); 

    InputStream is = zif.getInputStream(fh); 

    byte buf[] = new byte[1024]; 

    int numread; 

    while((numread = is.read(buf,0,1024))>=0) 

    { 

    out.write(buf, 0, numread); 

    } 

    is.close(); 

    out.flush(); 

    out.close(); 

    } 

    return true; 

} 

catch (FileNotFoundException e) 

{ 

    Log.v("comicsZip", "unZip()=" + e);  

} 

catch (IOException e) 

{ 

    Log.v("comicsZip", "unZip()=" + e + " Page="+page); 

} 

return false; 

} 
+0

e.printStackTrace() 및/또는 e.getMessage()를 수행하고 내용을 확인하십시오. 긴 메시지는 문제를 설명 할 수 있습니다. –

+0

예외가 발생하는 곳을 확인하십시오 ........ – Dinash

답변

0

입력을 닫는 중 문제가 발생한 것일 수 있습니다. 각 ZipEntry가 처리 된 후에는 전체 ZipInputFile의 끝에 한 번만 수행해야합니다 ('zif'가 맞다고 가정합니다).