• Post Reply Bookmark Topic Watch Topic
  • New Topic

text files creation  RSS feed

 
Joe Fett
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to create multiple text files using the class Formatter?

Here is the instructions for this program: "Write a program to create data for testing the (file-matching accounts receivable) program. Use sample account data from blah blah blah. Run the program to create the files trans.txt and oldmast.txt, to be used by your file-matching program."

I've seen in the text where I can create one text file using the class Formatter but can it create more than one within it?

Thanks for the help.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you'd need to create two Formatter objects. But I assume that the files will contain different content anyway, so it's not like using just one Formatter makes things much easier, right?
 
Joe Fett
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
No, you'd need to create two Formatter objects. But I assume that the files will contain different content anyway, so it's not like using just one Formatter makes things much easier, right?


That makes perfect sense and is what I suspected.

And yes, both text files will have slightly different formats.

Thanks for the help.
 
Joe Fett
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since that question was answered, I'd like to know something else. If I want to write to more than one text file, is the following code a good or not-so-good way to begin?

I guess the better question is should I make a new java class file for each text file I need to write to?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!