Unzip a file in linux using java

Below is the java code which can be used to unzip a folder

try{
String command="unzip -o "+path+""+fname+" -d "+path+""+unzippedfoldername;
Process process1 = Runtime.getRuntime().exec(command);
process1.waitFor();
 
String removecommand="rm "+path+""+fname;
process1 = Runtime.getRuntime().exec(removecommand);
process1.waitFor(); 
 
}catch(Exception err)
{
//
}

No comments:

Post a Comment