开发者

(JAVA) How open a temp htm file in browser?

I tried this, but without sucess:

         File temp = File.createTempFile("document", ".htm");

         BufferedWriter out = new BufferedWriter(new FileWriter(temp));
         out.write开发者_如何学C("hi !!!"); 
         out.close();

         System.out.println(temp.toURI().toString());


         java.awt.Desktop.getDesktop().browse(temp.toURI());


Works for me in slightly modified form:

    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();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜