[java] 자바에서 압축 파일의 크기 가져오기
import java.io.File;
import java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class ZipFileSize {
    public static void main(String[] args) {
        File file = new File("path/to/your/file.zip");
        long totalSize = 0;

        try (ZipInputStream zis = new ZipInputStream(new FileInputStream(file))) {
            ZipEntry entry;
            while ((entry = zis.getNextEntry()) != null) {
                totalSize += entry.getSize();
            }
            System.out.println("Total size of the ZIP file: " + totalSize + " bytes");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

위의 예제에서는 ZipInputStream을 사용하여 ZIP 파일의 크기를 가져오고 있습니다. 주어진 ZIP 파일의 각 엔트리의 크기를 반복적으로 합산하여 총 크기를 얻을 수 있습니다.

참고 문헌: