• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Recieving info from Windows when doing IO operations

 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic