黑马程序员技术交流社区
标题:
Runtime exec方法
[打印本页]
作者:
刘勇强
时间:
2013-6-13 19:46
标题:
Runtime exec方法
本帖最后由 刘勇强 于 2013-6-13 21:03 编辑
package kth.com;
import java.io.File;
import java.io.IOException;
public class ShowDir {
/*****
* @param args
* @throws InterruptedException
* @throws IOException
*/
public static void main(String[] args) throws IOException, InterruptedException {
// TODO Auto-generated method stub
File dir = new File("F:\\pic\\fe\\hui");//里面全是图片
showDir(dir);
}
public static void showDir(File dir) throws IOException, InterruptedException
{
System.out.println(dir);
File[] files = dir.listFiles();
for(int i=0;i<files.length;i++)
{
if(files[i].isDirectory())
showDir(files[i]);
else
{
File ff = new File("C:\\Users\\Patric\\Desktop\\wspace\\Exercise\\"+files[i].getName());
files[i].renameTo(ff);//复制到当前目录下
Runtime rt = Runtime.getRuntime();
String str = ff.getName();
System.out.println(str);//输出显示正确,都是正确的图片文件名
rt.exec("D:\\Program Files (x86)\\Google\\Picasa3\\PicasaPhotoViewer.exe str");//问题在这里:想用软件把每一张图片打开,但这里无任何反应 请问问题在哪里?
Thread.sleep(1000);
}
}
}
}
复制代码
作者:
许庭洲
时间:
2013-6-17 20:54
值得学习ing!
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2