Runtime 类部分常用方法
public Process exec(String command)//执行本地命令 public long freeMemory()//返回JVM的空闲内存量 public void gc()//运行垃圾回收方法,释放空间 public long MaxMemory()//返回JVM的最大内存量 public static Runtime getRuntime()//获得Runtime实例
package net.jsu.com;
import java.io.IOException;
public class Neicun {
public static void main(String[] args) throws IOException{
Runtime runtime = Runtime.getRuntime();
runtime.gc();
long maxMemory = runtime.maxMemory();
long freeMemory = runtime.freeMemory();
long usedMemory = maxMemory-freeMemory;
System.out.println("JVM的最大内存量:"+maxMemory
+"\n"+"JVM的空闲内存:"+freeMemory+"\n"
+"JVM已经使用的内存:"+usedMemory
);
runtime.exec("文件路径");
}
}