티스토리 뷰

public static boolean createZipFile(String sourceFile, String createZip) throws IOException{

boolean result=true;

byte[] buf=new byte[1024];

try{

ZipOutputStream zipOut=new ZipOutputStream(new FileOutputStream(createZip));

File inFile=new File(sourceFile);

FileInputStream in=new FileInputStream(inFile);

zipOut.putNextEntry(new ZipEntry(inFile.getName()));

int len;

while((len=in.read(buf))>0){

zipOut.write(buf,0,len);

}

in.close();

zipOut.closeEntry();

zipOut.close();

result=true;

}catch(IOException e){

result=false;

e.printStackTrace();

}finally{

return result;

}

}

'자바(Java) > 자바UTIL' 카테고리의 다른 글

[자바] 문자에서 숫자 한글만 추출  (0) 2018.10.23
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함