记一次错误
背景:项目中有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往文件中插入数据
