Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with directory/file  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys:
Sorry to also post this here. I just found we have a I/O forum.
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......
--------------------
Discussions reveal the truth.
Je pense, donc je ne suis pas.
--Anti-Descartes:
Quel est le moyen de la conscience pour �tre dans ce monde ? Ce monde est mati�re. Il faut donc un moyen mat�riel pour �tre. Mon moyen mat�riel d'exister est le corps. C'est lorsque je suis conscient de moi-m�me, de mon corps, et du monde qui m'entoure que je suis.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of the code from that snippet should produce a FileNotFoundException. Have you put in a few lines of debug to make sure you know exactly where the error is coming from?
Also, your exception shows 1111.dat, but your code shows you making 4444.dat. I'm thinking there is more to the problem than what the code is showing, so if you could show either more of your code, or as mentioned stick in some debugs and find the point where the exception is being thrown, we could help you a bit more.
 
Pavel Halas
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by victor gu:
It seems the code is calling native method.

Yes. The virtual machine is your platform, but it must translate your Java calls to OS native calls.
The directory (on the path) or the file don't exist. You have to not forget that new File object is not real file or directory. Use something like this:

But I may be wrong due to your not showing us the right code part.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!