• Post Reply Bookmark Topic Watch Topic
  • New Topic

Recieving info from Windows when doing IO operations  RSS feed

 
John Landon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

Thanks,
John.

PS
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)
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Landon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That wont help me.
I already did all this. My question is how to make java return the result of the OS call.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Landon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went to the last line of the stacktrace. This is the method that is being called:
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't really tell us anything.

I'm assuming you're calling the 3-arg createTempFile method. So do this:

 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"I think Java is lying because the directory is there" - bet you £1000 Java ain't lying and the dir ain't there.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!