Windows下java呼び出しwinrar圧縮ファイルはrar形式

1302 ワード

Windows下java呼び出しwinrar圧縮ファイルはrar形式
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class RARFileRun {

	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException , IOException, InterruptedException{
		String str="testrun.bat \"test rar file-2.xls\"";
		Process process=Runtime.getRuntime().exec(str);
		
		BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
		 String line;   
		  while ((line = br.readLine()) != null) {   
		   System.out.println(line);
		  }  
		  br = new BufferedReader(new InputStreamReader(process.getErrorStream(), "gbk"));   
		  while ((line = br.readLine()) != null) {   
		    //System.err.println(line);   
		  }   
		  // 。 
  
		  process.waitFor(); 
		System.out.println("OK");
	}

}

 
 
 
 
 
set b=%1%
set a=%~dp0
cd %a%
"C:\Program Files\WinRAR\WinRAR" a %a%%b%.rar %b%