标签:
前提需要知道怎么在linux怎么新建java文件和怎么编译,否则请先学其他知识!!
import java.io.*;
public class Test{
public static void main(String[] args) throws Exception{
try{
Process process=Runtime.getRuntime().exec("ls ./");
InputStreamReader reader = new InputStreamReader(process.getInputStream());
LineNumberReader line = new LineNumberReader(reader);
String str;
while((str=line.readLine())!=null){
System.out.println(str);
}
}catch (Exception e){
e.printStackTrace();
}
System.out.println("done !!!");
}
}
标签:
原文地址:http://www.cnblogs.com/ning-blogs/p/4682310.html