나는 압축 파일이 있습니다. 이 파일에는 다양한 디렉토리와 파일도 들어 있습니다. 모든 것을 추출하여 지정된 경로에 저장하고 싶습니다.자바를 사용하여 zip 파일을 추출하는 가장 좋은 방법은 무엇입니까
그래서 압축 된 파일을 추출하는 Java 프로그램을 작성하는 방법.
감사 선일 쿠마르 Sahoo
나는 압축 파일이 있습니다. 이 파일에는 다양한 디렉토리와 파일도 들어 있습니다. 모든 것을 추출하여 지정된 경로에 저장하고 싶습니다.자바를 사용하여 zip 파일을 추출하는 가장 좋은 방법은 무엇입니까
그래서 압축 된 파일을 추출하는 Java 프로그램을 작성하는 방법.
감사 선일 쿠마르 Sahoo
public static void unzip(){
try{
BufferedOutputStream out = null;
ZipInputStream in = new ZipInputStream(ZipFileExtracter.class.getClassLoader().getResourceAsStream("com/artificialmachines/chitme/stamps/ChitMeData.zip"));
ZipEntry entry;
boolean isDirectory=false;
while((entry = in.getNextEntry()) != null){
int count;
byte data[] = new byte[BUFFER];
// write the files to the disk
String entryName = entry.getName();
File newFile = new File(new StringBuffer().append(System.getProperty("user.dir")).append(File.separator).append(entryName).toString());
if(entryName.endsWith("/")){
isDirectory=true;
newFile.mkdir();
//System.out.println("This is directory "+newFile.exists()+" IS DIr "+newFile.isDirectory()+" path "+newFile.getPath());
}else{
newFile.createNewFile();
}
if(!isDirectory){
out = new BufferedOutputStream(new FileOutputStream(newFile),BUFFER);
while ((count = in.read(data,0,BUFFER)) != -1){
out.write(data,0,count);
}
cleanUp(out);
}
isDirectory=false;
}
cleanUp(in);
}
catch(Exception e){
e.printStackTrace();
System.exit(0);
}
}
의
당신은 java.util.zip
package를 사용하여 조사한다. Sun은 사용 방법에 대한 자습서 (Compressing and Decompressing Data Using Java APIs)를 제공합니다.
. http://lmgtfy.com/?q=java+unzip이 경우 가장 좋은 URL 일 수 있습니다. –
java.util.zip. *은 필수 항목입니다. refernec 용 API를 살펴보십시오. 당신은 예를 찾고 있다면 LookThis
가능한 중복 [반복적으로 자바에서 파일을 압축 해제하는 방법?] (http://stackoverflow.com/questions/981578/how-to-unzip-files-recursively-in -java) – Kevin