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......
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