• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing and reading files  RSS feed

 
Jacob Sousie
Ranch Hand
Posts: 53
1
Eclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a Java program that outputs your name, today's date, and five lines of your favorite PG-rated poem to the file "poem.txt".


Okay so I've been messing around with this trying to figure out how to write to a file and then print the file.
Am I on the right track?







 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jacob Sousie wrote:
Am I on the right track?


Well, when you ran it, did it generate the file? And did it contain what you were expecting?

Henry
 
Jacob Sousie
Ranch Hand
Posts: 53
1
Eclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Jacob Sousie wrote:
Am I on the right track?


Well, when you ran it, did it generate the file? And did it contain what you were expecting?

Henry


I checked my files and its there and it works.  now how do I read the file and print it?   can I read and print in the same program?
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would advise against reading and writing the same file simultaneously; that might actually not be possible because files lock themselves.
I suggest you start with the appropriate Java Tutorials section.
 
Fred Kleinschmidt
Bartender
Posts: 571
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now how do I read the file and print it?

Why do you want to write a Java program to print your file? It is mush easier just to use your platform's print command.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!