Search This Blog

Total Pageviews

Java Program to Unzip a file and Writing to a text file using try-with-resource feature

 *  Program to Unzip a file content to a text file using try-with-resource feature.
public class ReadAZipFile

    /** Pass, the outputfilename and zipFilename in args[] array when executed **/

    public static void main(String args[]) throws Exception {
        java.nio.charset.Charset charset =
        java.nio.file.Path outputFilePath =

        try (
                java.util.zip.ZipFile zipfile =
                new java.util.zip.ZipFile(args[1]);
                java.io.BufferedWriter writer =
                        java.nio.file.Files.newBufferedWriter(outputFilePath, charset)
                ) {
            for (java.util.Enumeration entries =
                    zipfile.entries(); entries.hasMoreElements();) {
                String newLineSeperator = System.getProperty("line.separator");
                String zipEntryName =
                        ((java.util.zip.ZipEntry)entries.nextElement()).getName() +
                writer.write(zipEntryName, 0, zipEntryName.length());

No comments:

java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport

SpringBoot Error: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.j...