package com.swing.demo; import java.io.File;
import java.io.IOException; public class OpenDirTest {
public static void main(String[] args) {
try {
java.awt.Desktop.getDesktop().open(new File("D:\\Java"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
备用方式:
try {
String[] cmd = new String[5];
cmd[0] = "cmd";
cmd[1] = "/c";
cmd[2] = "start";
cmd[3] = " ";
cmd[4] = FILE_PATH;
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}