Results 1 to 4 of 4

Thread: Help Plase

  1. #1
    Aggy is offline Member
    Join Date
    Jan 2010
    Location
    England
    Posts
    15
    Rep Power
    0

    Default Help Plase

    Hello, Am having trouble with the following code, when I compile it I get no errors but when I run it I "An error has occur: java.util.NoSuchElementException"


    public void readInCompetitors()
    {
    String pathname = OUFileChooser.getFilename();
    File bFile = new File(pathname);
    BufferedReader bufferedFileReader = null;
    try
    {
    bufferedFileReader = new BufferedReader(new FileReader(bFile));
    String currentLine = bufferedFileReader.readLine();
    String name;
    String sex;
    Integer age;
    String ageGroup;
    Scanner lineScanner;
    Integer time;
    while (currentLine != null)
    {
    lineScanner = new Scanner(currentLine);
    lineScanner.useDelimiter(",");
    Competitor runner = new Competitor();
    runner.setName(lineScanner.next());
    runner.setSex(lineScanner.next());
    System.out.print("e");
    age = lineScanner.nextInt();
    if (age < 18)
    {
    runner.setAgeGroup("junior");
    }
    else if (age > 55)
    {
    runner.setAgeGroup("senior");
    }
    else
    {
    runner.setAgeGroup("standard");
    }
    runner.setTime(Integer.parseInt(OUDialog.request(" Enter Time for Competitor: ")));
    currentLine = bufferedFileReader.readLine();
    competitors.add(runner);
    }
    }
    catch (Exception anException)
    {
    System.out.println("An error has occur: " + anException);
    }
    finally
    {
    try
    {
    bufferedFileReader.close();
    }
    catch (Exception anException)
    {
    System.out.println("An error has occur: " + anException);
    }
    }
    }

    As I am trying to learn I would appreciate any pointers please.

    thanks and kind regards

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Help Plase

    Please use [code] tags [/code] when posting code.
    Also, use <exception>.printStackTrace() to get the full exception data, rather than your current println() in the catch blocks.
    Then supply us that full exception info including stack trace, and point out the line on which the exception occurs.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: Help Plase

    Also, use a meaningful subject line. "Help Plase" isn't one.

    db

    edit: As you were told more than two years ago: Hello
    Last edited by DarrylBurke; 04-25-2012 at 04:30 PM.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,956
    Rep Power
    8

    Default Re: Help Plase

    Quote Originally Posted by Aggy View Post
    Help Plase
    I'm not sure what plasing is, but if you show me how, I'll be happy to help you to plase.

    Google tells me that Plase is a village in Albania. Are you asking for them to help you? You might want to post in an Albanian forum instead.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. plase help me
    By nassir in forum JCreator
    Replies: 38
    Last Post: 12-24-2009, 07:38 PM

Posting Permissions

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