Results 1 to 4 of 4
Thread: Help Plase
- 04-25-2012, 02:39 PM #1
Member
- Join Date
- Jan 2010
- Location
- England
- Posts
- 15
- Rep Power
- 0
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
- 04-25-2012, 02:42 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
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.
- 04-25-2012, 04:23 PM #3
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: HelloLast edited by DarrylBurke; 04-25-2012 at 04:30 PM.
Why do they call it rush hour when nothing moves? - Robin Williams
- 04-25-2012, 04:37 PM #4
Re: Help Plase
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
-
plase help me
By nassir in forum JCreatorReplies: 38Last Post: 12-24-2009, 07:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks