/** * FlashPaper 轉化文檔為swf格式,使用Flexpaper顯示,但是顯示有問題 * * */public class ConverterUtil { /** * * * @param swfFileSrc swf文件的存放路徑 * @param swfFileName swf文件的名字,后綴名要加上 * @param sourceFileSrc 源文件的存放路徑 * @param sourceFileName 源文件的名字,后綴名要加上 * @return 返回轉換成功與否 * 注意:路徑以及文件名不能帶空格,否則將無法轉換成功 */ public static boolean converter(String swfFileSrc, String swfFileName, String sourceFileSrc, String sourceFileName){ String flashPaperSrc = "C:/FlashPaper 2/FlashPRinter.exe";//FlashPaper啟動路徑 File sourceFile; //轉換源文件 File swfFile; //SWF目標文件 sourceFile = new File(sourceFileSrc + sourceFileName); swfFile = new File(swfFileSrc + swfFileName); int sleeptime = 0;//進程掛起時間,初始設置為0 boolean st_return = true;//文件轉換成功標識 Runtime pro = Runtime.getRuntime(); if(sourceFile.exists()) { if (!swfFile.exists()) { try { String converter = flashPaperSrc + " -o " + swfFileSrc + swfFileName + " " + sourceFileSrc + sourceFileName; //執行flashPaper轉換功能 pro.exec(converter); Thread.sleep(sleeptime); } catch (Exception e) { System.out.println("文件轉換失敗"); e.printStackTrace(); } return st_return; } else { st_return = false; System.out.println("服務器已存在同名的swf文件"); return st_return; } } else { st_return = false; System.out.println("源文件不存在,請檢查路徑是否正確"); return st_return; } } public static void main(String[] args) { converter("d:/","1.swf","d:/","test.docx"); }}
新聞熱點
疑難解答