*
The moose likes Beginning Java and the fly likes Formatter question(File) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Formatter question(File)" Watch "Formatter question(File)" New topic
Author

Formatter question(File)

Steven Alvarez
Ranch Hand

Joined: Nov 01, 2006
Posts: 66
I DON'T WANT SOMEONE TO WRITE THIS PROGRAM, I just need help.

The question goes as follows:


(Student Poll) Figure 7.8 contains an array of survey responses that is hard coded into the program. Suppose we wish to process survey results that are stored in a file. This exercise requires two separate programs. First, create an application that prompts the user for survey responses and outputs each response to a file. Use a Formatter to create a file called numbers.txt. Each integer should be written using method format. Then modify the program in Fig. 7.8 to read the survey responses from numbers.txt. The responses should be read from the file by using a Scanner. Method nextInt should be used to input one integer at a time from the file. The program should continue to read responses until it reaches the end of file. The results should be output to the text file "output.txt".


The part I need help in is understanding this part:

Use a Formatter to create a file called numbers.txt. Each integer should be written using method format.


Can I use the FileWriter class? Or do I have to use "Formatter" to write the file? If so, can you give an example of how to do so?

Also what does this part mean?

Each integer should be written using method format.


Thanks!!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

Steven Alvarez wrote:Can I use the FileWriter class?

You can, but then you would do the hard work.

Or do I have to use "Formatter" to write the file? If so, can you give an example of how to do so?

You need to use Formatter (I think they refer to java.util.Formatter). After all, that's the requirement.

Also what does this part mean?

Each integer should be written using method format.

I think if you click on that java.util.Formatter link and look through that API page you will get what they are asking of you.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Formatter question(File)
 
Similar Threads
please help me
can someone please help me
need help i have assighment to finish before end of day
text files creation
please help me