thuliobuarque / java2word

Automatically exported from code.google.com/p/java2word
0 stars 0 forks source link

Getting nullpointer exception #97

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
HI,

I am getting below error .please help some body.
TestUtils.createLocalDoc(xmlTemplate); 
above line i am getting error .

java.io.FileNotFoundException: null\Java2word_allInOne.doc (The system cannot 
find the path specified)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
    at java.io.PrintWriter.<init>(PrintWriter.java:218)
    at word.utils.TestUtils.createLocalDocument(TestUtils.java:58)
    at word.utils.TestUtils.createLocalDoc(TestUtils.java:30)
    at Java2Example.main(Java2Example.java:60)
java.lang.NullPointerException
    at word.utils.TestUtils.createLocalDocument(TestUtils.java:64)
    at word.utils.TestUtils.createLocalDoc(TestUtils.java:30)
    at Java2Example.main(Java2Example.java:60)

Src Code :

String xmlTemplate = Utils.readFile("C:/ReleaseNotesTemplate.doc");

                xmlTemplate = replacePh(xmlTemplate, "phCompanyName", "EasyWorld - coding for fun pty");
                xmlTemplate = replacePh(xmlTemplate, "phEnv", "Production");
                xmlTemplate = replacePh(xmlTemplate, "phVersion", "1.0 beta");
                xmlTemplate = replacePh(xmlTemplate, "phProjectLeader", "Leonardo Correa");

                Table tbl = new Table();
                tbl.addTableEle(TableEle.TH, "Jira Number", "Description");

                tbl.addTableEle(TableEle.TD, "J2W-1234", "Read Templates nicelly");
                tbl.addTableEle(TableEle.TD, "J2W-9999", "Make Java2word funky!!!");

                xmlTemplate = replacePh(xmlTemplate, "phTableIssues", tbl.getContent());

                Paragraph p01 = Paragraph.with("1) Stop the server").create();
                Paragraph p02 = Paragraph.with("2) Run the script to deploy the app xxx").create();
                Paragraph p03 = Paragraph.with("3) Start the server").create();
                Paragraph p04 = Paragraph.with("4) Hope for the best").create();

                String instructions = p01.getContent() + p02.getContent() + p03.getContent() + p04.getContent();

                //Workaround: phInstructions is already inside a 'text' fragment. 
                //If you know the template, you can remove the whole element and add all Paragraphs
                //* Table above doesn't need workaround because table can be normally inside a paragraph.
                xmlTemplate = replacePh(xmlTemplate, "<w:t>phInstructions</w:t>", instructions); 

                xmlTemplate = replacePh(xmlTemplate, "phDateTime", new Date().toString());

                System.out.println(xmlTemplate);
                TestUtils.createLocalDoc(xmlTemplate); 

Original issue reported on code.google.com by prathapr...@gmail.com on 16 Jul 2012 at 9:04

GoogleCodeExporter commented 8 years ago
Hi, is there a solution from this issue? i got this error and the post was 
posted 7 months ago. Thanks in advance!

Original comment by jcam...@gmail.com on 5 Feb 2013 at 6:16