- 소나큐브에 걸리지 않고 압축하기

public void archivingTheFile(String zipFile) { 
 
    byte[] buffer = new byte[1024]; 
    
    try (FileOutputStream fos = new FileOutputStream(zipFile); ZipOutputStream zos = new ZipOutputStream(fos)) { 
    
        for(String file : this.fileList) { 
        
            try (FileInputStream in = new FileInputStream(SOURCE_FOLDER + File.separator + file)) { 
                ZipEntry ze = new ZipEntry(file); 
                zos.putNextEntry(ze); 
                int len; 
                while ((len = in.read(buffer)) > 0) { 
                    zos.write(buffer, 0, len); 
                } 
            } 
        } 
    } 
    catch(IOException ex) { LOGGER.error("Exception occurred while zipping file",ex); }
}

'JAVA' 카테고리의 다른 글

lombok.jar 설치(설정)하기  (0) 2023.02.04

+ Recent posts