Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to write to a file using PrintWriter  RSS feed

 
abhinav sinha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am using the following code to create a file and write to it -

________________________________________________________________________
<code>

String md5sum = "my name is abhinav";
PrintWriter pw = new PrintWriter(new FileWriter("TestFileAbhinav"));
pw.println(md5sum);

</code>
_________________________________________________________________________

The file is getting created but the string is not getting written to the file.Where am I going wrong?Please help.
 
Sid Murrey
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a guess, did you try .flush()ing and .close()ing ?
 
abhinav sinha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it. I was not using pw.close() .
Thanks for your reply anyways.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!