• Post Reply Bookmark Topic Watch Topic
  • New Topic

generating the output text file through java IO  RSS feed

 
naresh saxena
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-2 down vote favorite


I have developed a java code that reads files from the folder chosen by the user. It displays how many lines of code are in each file, it reads only .java filesonly and final outcome is shown on console , I was thinking that output to be get displayed on console but along with a text file conataing the same information to be get stored on desktop also, please advise how to that and the name of the file that is generated its name is to be based on timestamp lets assume that name of the output file would be 'output06282012' and that text file should contain the same information that is shown on the console , here is my piece of code...



Please advise
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) construct the file name you want to use
2) open the file for write
3) each time you call a System.out.println(), make a similar call to write the same message to the file
4) when you are all done, make sure you close the file handle.
 
naresh saxena
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:1) construct the file name you want to use
2) open the file for write
3) each time you call a System.out.println(), make a similar call to write the same message to the file
4) when you are all done, make sure you close the file handle.


I have an rough idea something like this



but could you please show in code terms as I HAVE DONE
 
Michael Dunn
Ranch Hand
Posts: 4632
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naresh saxena wrote:but could you please show in code terms as I HAVE DONE

Show what ? You appear to know know how to write to a file, you appear to know how to get the data that you want to write to that file, so just put it all together.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!