• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not displaying integers when writing to a text file in netbeans

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 113
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Shawn,

Wrapping the FileOutputStream in a PrintWriter should solve your problem.

Code is as given below:




 
reply
    Bookmark Topic Watch Topic
  • New Topic