我试过了,但没有成功:
File temp = File.createTempFile("document", ".htm");
BufferedWriter out = new BufferedWriter(new FileWriter(temp));
out.write("hi !!!");
out.close();
System.out.println(temp.toURI().toString());
java.awt.Desktop.getDesktop().browse(temp.toURI());
答案 0 :(得分:2)
以略微修改的形式为我工作:
File temp;
try {
temp = File.createTempFile("document", ".htm");
BufferedWriter out = new BufferedWriter(new FileWriter(temp));
out.write("hi !!!");
out.close();
System.out.println(temp.toURI().toString());
java.awt.Desktop.getDesktop().browse(temp.toURI());
} catch (IOException e) {
e.printStackTrace();
}