Decompression in the JAVA JDK does not seem to decompress our manually compressed RAR files, only the JDK API compressed RAR
So come up with the following WinRAR command line decompression
Package edu.nwpu.vcampus.util; Import Java.io.File; public class Ziputil {public static final String Winrarpath = ' C://program files//winrar//winrar.exe '; public static bool EAN unzip (String ZipFile) {Boolean bool = false; File F=new file (ZipFile); if (!f.exists ()) {return false;} String folder = F.getparent (); System.out.println (folder); String cmd = winrarpath + "X" + ZipFile + "" +folder; cmd= "C://program files//winrar//winrar.exe X d://a.rar d://a"; System.out.println (CMD); try {Process proc = runtime.getruntime (). exec (cmd); if (proc.waitfor ()!= 0) {if (proc.exitvalue () = = 0) {bool = false; } else {bool = true;}} catch (Exception e) {e.printstacktrace ();} return bool; public static Boolean unzip (String zipfile,string password) {boolean bool = false; File F=new file (ZipFile); if (!f.exists ()) {return false;} String folder = F.getparent (); System.out.println (folder); String cmd = winrarpath + "x-p" + password+ "" +zipfile + "" +folder; cmd= "C://program files//winrar//winrar.exe X d://a.rar d://a "; System.out.println (CMD); try {Process proc = runtime.getruntime (). exec (cmd); if (proc.waitfor ()!= 0) {if (proc.exitvalue () = = 0) {bool = false; } else {bool = true;}} catch (Exception e) {e.printstacktrace ();} return bool; public static void Main (string[] args) {String ZipFile = ' D://a.rar '; Boolean b = Ziputil.unzip (ZipFile); System.out.println (b); } }