import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; public class  PdfConvertUtil { public static  String 转换(String filePath String outPath) { File File =, new 文件(filePath); 时间=String , msg “”; String realName =, outPath +“\ \”+ file.getName () .substring (0, file.getName () . length() 3) +“主权财富基金”; 如果(pdf .equals (PdfConvertUtil.getPostfix (filePath))) { try { StringBuffer cmd =, new StringBuffer (“D: \ \ swftools \ \ pdf2swf.exe ”); cmd.append (“, -o ”);//输出 cmd.append (realName); cmd.append (“, -t ”); cmd.append (filePath);//输入文件 cmd.append (“, -T -z  -s languagedir=D: \ \ xpdf-chinese-simplified -s flashversion=9 ");//System.out.println (cmd.toString ()); Process p =, Runtime.getRuntime () .exec (cmd.toString ()); BufferedReader reader =, new BufferedReader (new InputStreamReader (p.getInputStream ())); String line =,””; 而((=line reader.readLine ()), !=, null) { System.out.println(线); 如果(line.indexOf (“Writing SWF file ”),在=,0){ 时间=msg “PDF转换SWF成功!”; } } 如果(p.waitFor (), !=, 0) { 如果(p.exitValue (),==, 1) { 时间=msg “PDF转换SWF失败!”; } } },catch (IOException e), { e.printStackTrace (); },catch (InterruptedException e), { e.printStackTrace (); } 其他}{ msg =,”文件不是PDF格式!”; } return 味精; } public static  String getPostfix (String filePath) { File File =, new 文件(filePath); 如果(file.isFile ()) { String fileName =, file.getName (); return fileName.substring (fileName.lastIndexOf (“。”) + 1) .toLowerCase (); } return “”; } public static  void main (String [], args), { String filePath =, " C: \ \ \ \ \ \管理员用户下载\ \ nodejs开发指南\ \ node . js开发指南. pdf”; System.out.println (PdfConvertUtil.convert (filePath " C: \ \ \ \ \ \管理员用户下载\ \ nodejs开发指南")); } }