Results 1 to 4 of 4
  1. #1
    Wolfsy is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default Reading in a file

    I do not get why this code doesnt work:

    import java.util.Random;

    public class Highscore{

    public int setHighscore; //setter needs to be private
    protected int getHighscore;
    public IOException;

    public Highscore(int setHighscore, int getHighscore){
    this.setHighscore = setHighscore;
    this.getHighscore = getHighscore;

    public void setHighscore(int Highscore){

    public Highscore() throws IOException {

    private void getHighscoreFromFile() throws IOException {
    FileReader input = new FileReader("highscore.txt");
    BufferedReader file = new BufferedReader(input);

    All I want to do is read in a file but it is saying that there is something wrong with the IOException?!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: Reading in a file

    If you want help, you'll have to provide an SSCCE as well as the full stack trace of the error, including the line it occurs on. Where is the file located? Where does your relative path point to? Create a File instance there and print out its absolute path if you aren't sure.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Reading in a file

    Indeed, does it compile?
    If not, what is the full text of the compilation error?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Bali, Indonesia
    Rep Power

    Default Re: Reading in a file

    I believe this line that cause you an error:

    Java Code:
    public IOException;

Similar Threads

  1. Reading file external to jar file
    By nn12 in forum New To Java
    Replies: 6
    Last Post: 02-04-2011, 05:46 AM
  2. help regarding reading file in JSf
    By tajinder in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 09-13-2010, 04:25 PM
  3. reading a file and writing to a!!!!
    By java_prgr in forum New To Java
    Replies: 3
    Last Post: 07-26-2010, 06:53 PM
  4. Replies: 9
    Last Post: 10-20-2009, 10:52 AM
  5. Replies: 3
    Last Post: 05-09-2009, 11:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts