小编nec*_*d69的帖子

用Java生成PDF

我正在尝试用Java编写一个PDF文件来说出这些文字hello neckbeards但是当我运行我的程序时,Adobe Reader会打开,但是出现了一个错误:

There was an error opening this document.
The file is already open or in use by another application.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import java.awt.Desktop;
import java.io.*;

public class count10 {

    public static void main(String[] args) throws Exception {

        File tempfile = File.createTempFile("report", ".pdf");
        FileWriter pfile = new FileWriter(tempfile);
        pfile.write("hello neckbeards");

        Desktop dtop = null;

        if (Desktop.isDesktopSupported()) {
            dtop = Desktop.getDesktop();
        }
        if (dtop.isSupported(Desktop.Action.OPEN)){
            String path = tempfile.getPath();
            dtop.open(new File(path));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java pdf io pdf-generation

1
推荐指数
1
解决办法
3137
查看次数

任何人都有Java的初始代码的简单代码示例?

只是想知道有没有任何人链接到基本的启动画面代码或示例?

java splash-screen

1
推荐指数
1
解决办法
570
查看次数

标签 统计

java ×2

io ×1

pdf ×1

pdf-generation ×1

splash-screen ×1