Anyone knows how to receive information from Windows when having trouble writing to a directory?
Here is the stacktrace:
INFO | jvm 1 | 2012/11/07 12:33:39 | java.io.IOException: The system cannot find the path specified
INFO | jvm 1 | 2012/11/07 12:33:39 | at java.io.WinNTFileSystem.createFileExclusively(Native Method)
INFO | jvm 1 | 2012/11/07 12:33:39 | at java.io.File.checkAndCreate(File.java:1704)
INFO | jvm 1 | 2012/11/07 12:33:39 | at java.io.File.createTempFile(File.java:1792)
INFO | jvm 1 | 2012/11/07 12:33:39 | at org.apache.pdfbox.cos.COSDocument.<init>(COSDocument.java:116)
INFO | jvm 1 | 2012/11/07 12:33:39 | at org.apache.pdfbox.cos.COSDocument.<init>(COSDocument.java:140)
INFO | jvm 1 | 2012/11/07 12:33:39 | at org.apache.pdfbox.cos.COSDocument.<init>(COSDocument.java:128)
INFO | jvm 1 | 2012/11/07 12:33:39 | at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:146)
INFO | jvm 1 | 2012/11/07 12:33:39 | at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:862)
INFO | jvm 1 | 2012/11/07 12:33:39 | at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:829)
I think Java is lying because the directory is there. I want to know why it cannot find the directory. What does Windows know about it.
It has nothing to do with pdf api. Its java io. I do know that its trying to write to the path I think its trying to write to (tomact/temp)
javi.io.File has some methods that could help you. File.getCanonicalPath() and File.exists() would be a good start. After that, you might look at Windows' File Explorer and see if the user who's running the Java application has permission to create a file in the directory.
You could attach a debugger, and step through the API calls and see whats' happening. Before I did that though...
That wont help me.
I already did all this.
It will help if you make the appropriate tests, and you tell us what those tests were and what results they gave. For example...
If using the 2-arg version of createTempFile, or passing null for the 3rd arg you checked canWrite() for the File corresponding to System.getProperty("java.io.tmpdir")?
If using the 3-arg version and passing non-null for the 3rd arg, you checked .isDirectory() and .canWrite()?
I get that same exception when I do
So if I do
I get false.
So then if I tell myself, "Nonsense! I know that directory exists!", I try this:
And lo and behold, that relative path doesn't correspond to where I thought it would.
It sounds like you may be making similar faulty assumptions, but since we don't have the details of which method signature you called with what args, and what exact other calls you made to test things and what their results were, there's not much concrete advice we can give.