aspose file tools*
The moose likes I/O and Streams and the fly likes Not displaying integers when writing to a text file in netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Not displaying integers when writing to a text file in netbeans" Watch "Not displaying integers when writing to a text file in netbeans" New topic
Author

Not displaying integers when writing to a text file in netbeans

Shawn Gee
Greenhorn

Joined: Apr 30, 2011
Posts: 1
Hi,

I am working on this and I have spent about 4 hours try to find a solution on the internet and just by working with the code to no end.

Create a Java application that:
creates a file called scores.txt
Write your name to the first line of the file.
Next use a loop to prompt the user for three numeric grades. Use a counter variable (i.e. intCounter) in the prompt. Write each grade to the file.

I have gotten here, but when I view the file the integers show up as letters.


THIS IS WHAT PRINTS OUT:

Shawn
Z
P
F



Thanks,
Shawn
Souvik Dasgupta
Ranch Hand

Joined: Sep 24, 2009
Posts: 77

Hello Shawn,

Wrapping the FileOutputStream in a PrintWriter should solve your problem.

Code is as given below:






Thanks and Regards, Souvik
SCJP, SCWCD, OCEJWSD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not displaying integers when writing to a text file in netbeans
 
Similar Threads
exception handling help
Code problems
trouble using .useDelimiter
IO / Serialization
Problem Using PrintWriter class !