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

file creation  RSS feed

 
pvsr rao
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have to create one file and write some string into it.
i have written like this
FileWriter f= new FileWriter("d:/sub/a.txt");
f.write("hello");
but a.txt is not creting on that directory.then i have replaced \ with//,
but same problem.file was not created in that directory
please tellme where is the problem
 
Stuart Ash
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can u post the exact code. Is this enclosed in a try-catch block?
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IO is buffered at several levels. The JVM, OS, and hardware all may keep output in memory for some time before it is actually written to the disk. If your program terminates before the data is written, it may be lost. Sometimes it is necessary to invoke flush() on an output stream to remind the JVM and OS to clear its buffers (some classes, PrintWriter for instance, can do this for you ). One should always invoke close() on a stream when he is done with it as well, so the JVM can clean up the file resources.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!