import java.io.*;
public class RuntimeTest
{
public static void main(String[] args)
{
//单例模式?
Runtime runtime = Runtime.getRuntime();
//测试exec
try{
Process p = runtime.exec("ping baidu.com");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inline;
while ((inline = br.readLine())!=null) {
System.out.println(inline);
}
}catch(IOException e){
e.printStackTrace();
}
//测试freeMemory()
System.out.println("freeMemory = "+runtime.freeMemory()/1024/1024);
//测试totalMemory()
System.out.println("totalMemory = "+runtime.totalMemory()/1024/1024);
System.out.println("Hello World!");
}
}