0

我试过这个,但没有成功:

         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());
4

1 回答 1

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();
    }
于 2010-07-16T15:48:45.500 回答