Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not displaying integers when writing to a text file in netbeans

 
Shawn Gee
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Shawn,

Wrapping the FileOutputStream in a PrintWriter should solve your problem.

Code is as given below:




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic