Java中调用文件中所有bat脚本

//调用外部脚本
String fileips=null;//所有的路径
String[] files=null;
String fileip=null;//单个路径
try {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("pdfconfig.properties"); //加载线程文件成为流
Properties prop = new Properties();
prop.load(is);
fileip = prop.getProperty("pdf_javatobatfile");
System.out.println("cccc" + fileip);
files=fileip.split(",");
System.out.println("长度:" + files.length);
} catch (IOException e) {
e.printStackTrace();
}
for (int j=0;j<files.length;j++){
fileip=files[j];

String fileName=fileip+File.separator;
File f=new File(fileName);
System.out.println(f);
if(f!=null){
if(f.isDirectory()){
File[] fileArray=f.listFiles();
if(fileArray!=null){
for (int i = 0; i < fileArray.length; i++) {
try {
Thread.currentThread().sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//递归调用

//调用bat脚本 有弹窗
try {
Runtime.getRuntime().exec("cmd.exe /C start "+fileArray[i]);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
else{
System.out.println(f);
}
}
}
posted @ 2017-04-18 11:37  国强则无惧!  阅读(556)  评论(0编辑  收藏  举报