I have a file e.g. test.zip. If I use a ZIP-tool like winrar, it\'s easy to extract (unzip test.zip to test.csv). But test.csv is not in UTF8 format. My problem here is, whe
can you try below code? For more examples check here http://java2novice.com/java-collections-and-util/zip/unzip/
FileInputStream fis = null;
ZipInputStream zipIs = null;
ZipEntry zEntry = null;
try {
fis = new FileInputStream(filePath);
zipIs = new ZipInputStream(new BufferedInputStream(fis));
while((zEntry = zipIs.getNextEntry()) != null){
try{
byte[] tmp = new byte[4*1024];
FileOutputStream fos = null;
String opFilePath = "C:/"+zEntry.getName();
System.out.println("Extracting file to "+opFilePath);
fos = new FileOutputStream(opFilePath);
int size = 0;
while((size = zipIs.read(tmp)) != -1){
fos.write(tmp, 0 , size);
}
fos.flush();
fos.close();
} catch(Exception ex){
}
}
zipIs.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}