String strcmd = "cmd /c start /b d:\\ocr\\b.bat";
Runtime rt=Runtime.getRuntime();
Process ps=null;
try{
ps=rt.exec(strcmd);
ps.waitFor();
}catch(IOException e1){
e1.printStackTrace();
}catch(InterruptedException e){
e.printStackTrace();
}
int i=ps.exitValue();
if(i==0){
System.out.println("執行完成!");
}else{
System.out.println("執行失敗!");
}
ps.destroy();
ps=null;
BufferedReader br =null;
try {
StringBuilder sb =new StringBuilder();
Process p=Runtime.getRuntime().exec("cmd /c start /b && d: && cd d:\\ocr\\ && XXX.exe");
br =new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=null;
while((line =br.readLine())!=null) {
sb.append(line+" \n");
}
}catch (Exception e) {
e.printStackTrace();
}finally {
if(br!=null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
String filePath="d:/ocr/work/~TMP0001.TXT";
File file=new File(filePath);
BufferedReader reader=null;
String tempString =null;
int line=1;
List<String> wenbenlist=new ArrayList<String>();
try{
reader=new BufferedReader(new InputStreamReader(new FileInputStream(file),"GBK"));
while((tempString=reader.readLine())!=null){
wenbenlist.add(tempString);
line++;
}
System.out.println(wenbenlist);
reader.close();
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e1){
e1.printStackTrace();
}finally{
if(reader!=null){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}