This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

writing to a file  RSS feed

 
macca cronin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there,

I'm new to java and I need to write a string that i generated in my code to an output file. I'm currently writing the string to the standard output like so :

System.out.println("K_"+Receiver+",t"+msgnum+"(R("
+Receiver+",t"+msgnum+"("+out1+")))");

All the types e.g. 'Receiver' or 'out1' are of type string. Could anyone show me how to open a file for writing and then write this information to the file? Is there some sort of file writer equivalent for system.out.println()? Thanks very much
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make yourself a cup of tea, sit down, and read through Sun's Java I/O Tutorial. Be sure to read the whole thing, especially "How to Use File Streams" and "How to Wrap a Stream". You want to use a FileWriter wrapped in a PrintWriter -- but please read the tutorial so you learn how things work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!