This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes problem with directory/file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem with directory/file " Watch "problem with directory/file " New topic
Author

problem with directory/file

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi, guys:
I urgently need your help. I am working on Win2K.
I try to create a directory, then insert a file into this directory, and write to this directory, such as the following:

......
File aDirectory = new File("Directory");
aDirectory.mkdir();
File aFileName = new File(aDirectory, "4444"+".dat");
....

When I test this piece of code, I got the following errors:

java.io.FileNotFoundException: 1111
.dat (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at com.kroger.DirectoryQueue.POGRequestQueueImpl.writeId(POGRequestQueueImpl.java:46)
at com.kroger.DirectoryQueue.QueueFileHandler.main(QueueFileHandler.java:10)
com.kroger.DirectoryQueue.POGRequestQueueException: Write error
at com.kroger.DirectoryQueue.POGRequestQueueImpl.writeId(POGRequestQueueImpl.java:53)
at com.kroger.DirectoryQueue.QueueFileHandler.main(QueueFileHandler.java:10)

It seems the code is calling native method. I am wondering what is causing these errors? My setup of directory or file names? Please give your thought.
Thanks......
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
I'm not sure I follow you. Do you mean you can't access the file from the line File aFileName = new File(aDirectory, "4444"+".dat");? If so, that's because until you write something to the file object there is no file, only an abstract representation. Your code executed fine on my machine which is also Win2K. Try something like this:

Then you should have a physical file on the system. Also note that java.io uses native methods to interact with the underlying OS file system.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
jQuery in Action, 2nd edition
 
subject: problem with directory/file
 
Similar Threads
File Name Too Long
Issue in saving XML data to file
Help with java.io.FileNotFoundException
Still need some help w/ IO and Data Conversion
problem with directory/file