java - unzip files are not in exact format -


I want to open all the folders and different types of files like .xls, .apk, .png etc. But while extracting all files are in their newly removed foder (or folder under folder). But those .xml, .png, .apk files are not in the proper format. When I open an XML file, it shows a pop that the format can be different, and when it opens, the files that all the content is in different formats. PNG files are also not able to open, neither Useful after removing .apk. Why is this happening ?? **

  Import java.io.buffferedInputStream; Import java.io.BuffferedOutputStream; Import java.io.file; Import java.io.FileInputStream; Import java.io.phileNotFoundException; Import java.io.FileOutputStream; Import java.io.IOException; Import java.util.zip.ZipEntry; Import java.util.zip.ZipInputStream; Public class UnzipFiles {public static zero main (string A []) {UnzipFiles mfe = new UnzipFiles (); Mfe.unzipFile ("E: / new folder / pics.zip"); } Public Zero UnzipFile (string file path) {FileInputStream fis = null; Zip inputstream zip = faucet; Zipantri zentry = null; {Fis = Try New FileInputStream (filePath); ZipIs = new zipprintstream (new buffering input (FIS)); While ((zEntry = zipIs.getNextEntry ()) = null) {try {byte [] tmp = new byte [25 * 1024 * 1024]; FileOutputStream fos = Faucet; / * String opfilepath = "E: / new folder / new /" + zEntry.getName (); * / String opfilepath = "E: / new folder / new" + File.Sseparator + zEntry.getName (); File f = new file (opfilepath); If (zEntry.is directory) {FMKDIR (); System.out.println (f.getName () + "" + "folder created"); } Else {System.out.println (f.getName ()); / * System.out.println ("+ opfilePath" is encrypting the file); * / Fos = new FileOutputStream (f); BufferedOutputStream Out = New BufferedOutputStream (fos); Int size = 0; Int k = zipIs.read (tmp); Println (k + 1); While ((size = zip id. Reed (tmp))! = -1) {out.write (tmp, 0, size); }}} Hold (Exception pre) {ex.printStackTrace (); }} ZipIs.closeEntry (); ZipIs.close (); } Hold (FileNotFoundException E) {// TODO Auto generated blocking block e.printStackTrace (); } Grip (IOException exc) {// TODO Auto-Generated Catch Block exc.printStackTrace (); 
Reads in the destination file:
  int k = zipIs.read (tmp); // & lt; --- System.out.printLN (K + 1); While ((size = zip id. Read (tmp))! = -1) {out.write (tmp, 0, size);   

In addition, if you use Java 7, instead, a ZIP FileSystem with files.walkFileTree () Use ; Which will make your job very more easy!

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -