Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FileNotFoundException when writing to the hard disk ???  RSS feed

 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.I have files read from client machine. And then I want to write them to the
server machine.

At the stage that the server wants to write files to the hard disk. I get FileNotFoundException sometimes. It doesn't happen every time. And even if it happens, it only happens to the one or the second file that server writes. All other files are OK.

Moreover, even if it fails at the first time. It never fails again if the client send another request.

Could anybody tell me why this random exception happen?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the stack trace? What's happening when the exception is thrown? Is it thrown while opening a FileOutputStream? Or is it something else?
 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The stack trace shows the error occurs when tryin to open the FileOutputStream.

Could you tell me what can I do with it?

Many thanks
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the directory where you are trying to write the file exist?
 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think so. I always check the file path and make sure the parent directory exists before writing the file. If it doesnt, I create the directory first before actually wrting to the file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!