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