日期:2014-05-18  浏览次数:20598 次

怎么生成不了pdf文档??
package   com.platform.common;

import   java.io.FileNotFoundException;
import   java.io.FileOutputStream;

import   com.lowagie.text.Document;
import   com.lowagie.text.DocumentException;
import   com.lowagie.text.Paragraph;
import   com.lowagie.text.pdf.*;
public   class   Importpdf{

        public   static   void   main(String[]   args)   {

                //创建一个文档对象

                Document   doc=new   Document();

                try   {

                //定义输出位置并把文档对象装入输出对象中

                      PdfWriter.getInstance(doc,   new   FileOutputStream( "c:/hello.PDF "));

                        //打开文档对象

                        doc.open();

                  //   加入文字“Hello   World”

                        doc.add(new   Paragraph( "HelloWorld "));

                  //     关闭文档对象,释放资源

                        doc.close();                        

              }   catch   (FileNotFoundException   e)   {

                      e.printStackTrace();

              }   catch   (DocumentException   e)   {

                      e.printStackTrace();

              }

        }

}
我怎么运行过后在c盘中没有helloword这个pdf文档啊???
请教高手!!

------解决方案--------------------
有没有异常?
------解决方案--------------------
程序没有任何问题,你再运行看看,或者尝试换个盘符试试。有可以跟权限有关
------解决方案--------------------
你可以直接运行这个类,在eclipse选中这个类文件,右键-> 运行方式-> java应用程序
我试过了,可以生成pdf文件
------解决方案--------------------
PdfWriter.getInstance(doc, new FileOutputStream( "c:/hello.PDF "));
中的“/”换成“\\”(windows系统)
“/”是linux系统的吧.