File URLs containing spaces
Posted: Thu Apr 28, 2011 8:25 am
When testing docx4j using the blog sample project provided under http://muammeryucel.blogspot.com/2011/01/manipulating-microsoft-docx-files-with.html, I recognized that the sample code works only if the document path to the template does not contain spaces.
The sample code has,
with Invitation having
resulting in the following docx4j stack trace
Is this a problem which can be cured by fixing docx4j or just windows file system / java nio stupidity?
The sample code has,
- Code: Select all
invitation = new Invitation(templateProperties, InvitationTest.class
.getResource("/template.docx").getPath(), InvitationTest.class
.getResource("/").getPath());
with Invitation having
- Code: Select all
WordprocessingMLPackage template = WordprocessingMLPackage
.load(new File(templateFilePath));
resulting in the following docx4j stack trace
- Code: Select all
org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't load file from C:\Users\Karsten%20Tinnefeld\Desktop\hello.world.docx4j\target\test-classes\template.docx
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:186)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:169)
at com.myucel.docx4j.Invitation.invite(Invitation.java:44)
[...]
Caused by: java.io.FileNotFoundException: C:\Users\Karsten%20Tinnefeld\Desktop\hello.world.docx4j\target\test-classes\template.docx (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:183)
... 31 more
Is this a problem which can be cured by fixing docx4j or just windows file system / java nio stupidity?