Linux创建文件失败


记一次错误

背景:项目中有word转pdf再转图片插入到pdf中防止修改pdf的方法,在word转PDF时,在Windows上无问题,但是在linux上PDF文件没有创建出来,下面是当时的代码

 try {
                long old = System.currentTimeMillis();
                Document doc = new Document(inPath);// 原始word路径
               
                String pdfFile = outPath;
                FileOutputStream fileOS = new FileOutputStream(outPath);
                doc.save(fileOS, SaveFormat.PDF);

                long now = System.currentTimeMillis();
                System.out.println("共耗时:" + ((now - old) / 1000.0) + "秒");
            } catch (Exception e) {
                e.printStackTrace();
            }

这是用outputStream传入一个路径,直接创建文件,但是Linux不能直接这么创建,需要先new一个file,然后再用outputStream往文件中插入数据


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM