Hi Folks, I'm trying to load a file up as I run my program.
I have a method called onLoad, but I havent been able to get it to load as yet. I have tried a number of things but cant get rid of the error message
C
jdk1.3.1\bin\Athletics.java:26: ';' expected
onLoad(athId) throws IOException;
This message comes up wether I use the throws or not.
Some code
####Main####
import java.io.*;
import java.awt.*;
import AthletesID;
public class Athletics
{
public static void main(String[] args)
{
//Declare variables
boolean done=false;
//Set array and initialise
AthletesID[] athId = new AthletesID[11];
for (int i = 0; i < 11; i++)
athId=new AthletesID();
onLoad(athId);
fileExist(athId) throws IOException;
while (! done)
{
System.out.println("\t===============================================================");
System.out.println("");
System.out.println("");
System.out.println("\t\tWelcome to the Ned Kelly Athletics Team. ");
System.out.println("");
System.out.println("\t\tPlease enter the events as 100m, 200m, 1000m. ");
System.out.println("");
System.out.println("");
System.out.println("\t===============================================================");
System.out.println("");
System.out.println("");
System.out.println("\tPlease enter a number from the menu choice, and press enter. ");
System.out.println("");
System.out.println("");
int menu=1;
do
{
System.out.println("\t1: New member. ");
System.out.println("\t2: Edit entry. ");
System.out.println("\t3: Delete entry. ");
System.out.println("\t4: Display data. ");
System.out.println("\t5: Display bar chart. ");
System.out.println("\t6: Exit program. ");
menu = DataIn.readLineInt();
switch (menu)
{
case 1: try
{ NewMember(athId);
} catch(IOException e)
{ System.out.println("NewMember IOException "+e);
}
break;
/*case 2: try
{ editEntry(athId);
} catch(IOException e)
{ System.out.println("editEntry IOException "+e);
}
break;
/*case 3: try
{ deleteEntry(athId);
} catch(IOException e)
{ System.out.println("deleteEntry IOException "+e);
}
break;
case 4: try
/* { displayData();
} catch(IOException e)
{ System.out.println("displayData IOException "+e);
}
break;
/*case 5: try
{ barChart(athId);
} catch (IOException e)
{ System.out.println("barChart IOException "+e);
}
break;*/
case 6: try
{ exitProgram(athId);
done = true;
} catch (IOException e)
{ System.out.println("exitProgram IOException "+e);
}
break;
default: System.out.println("Invalid entry, please choose one of the six menu choices. ");
}
}
while (menu < 6);
}
}
####Method####
public static void onLoad(AthletesID[] athId) throws IOException
{
DataInputStream istream;
int id, age;
String name, event;
double time;
istream= new DataInputStream(new FileInputStream("events.dat"));
try
{
for(int i=0;i<11;i++)
{
id = istream.readInt();
name = istream.readUTF();
age = istream.readInt();
event = istream.readUTF();
time = istream.readDouble();
athId.setathNum(id);
athId.setathName(name);
athId.setathAge(age);
athId.setathEvent(event);
athId.setathTime(time);
}
}
catch(IOException e)
{
System.err.println("File not opened");
}
finally
{
istream.close();
}
}
Many thanks for any help.
Regards Ne
I have a method called onLoad, but I havent been able to get it to load as yet. I have tried a number of things but cant get rid of the error message
C
jdk1.3.1\bin\Athletics.java:26: ';' expectedonLoad(athId) throws IOException;
This message comes up wether I use the throws or not.
Some code
####Main####
import java.io.*;
import java.awt.*;
import AthletesID;
public class Athletics
{
public static void main(String[] args)
{
//Declare variables
boolean done=false;
//Set array and initialise
AthletesID[] athId = new AthletesID[11];
for (int i = 0; i < 11; i++)
athId=new AthletesID();
onLoad(athId);
fileExist(athId) throws IOException;
while (! done)
{
System.out.println("\t===============================================================");
System.out.println("");
System.out.println("");
System.out.println("\t\tWelcome to the Ned Kelly Athletics Team. ");
System.out.println("");
System.out.println("\t\tPlease enter the events as 100m, 200m, 1000m. ");
System.out.println("");
System.out.println("");
System.out.println("\t===============================================================");
System.out.println("");
System.out.println("");
System.out.println("\tPlease enter a number from the menu choice, and press enter. ");
System.out.println("");
System.out.println("");
int menu=1;
do
{
System.out.println("\t1: New member. ");
System.out.println("\t2: Edit entry. ");
System.out.println("\t3: Delete entry. ");
System.out.println("\t4: Display data. ");
System.out.println("\t5: Display bar chart. ");
System.out.println("\t6: Exit program. ");
menu = DataIn.readLineInt();
switch (menu)
{
case 1: try
{ NewMember(athId);
} catch(IOException e)
{ System.out.println("NewMember IOException "+e);
}
break;
/*case 2: try
{ editEntry(athId);
} catch(IOException e)
{ System.out.println("editEntry IOException "+e);
}
break;
/*case 3: try
{ deleteEntry(athId);
} catch(IOException e)
{ System.out.println("deleteEntry IOException "+e);
}
break;
case 4: try
/* { displayData();
} catch(IOException e)
{ System.out.println("displayData IOException "+e);
}
break;
/*case 5: try
{ barChart(athId);
} catch (IOException e)
{ System.out.println("barChart IOException "+e);
}
break;*/
case 6: try
{ exitProgram(athId);
done = true;
} catch (IOException e)
{ System.out.println("exitProgram IOException "+e);
}
break;
default: System.out.println("Invalid entry, please choose one of the six menu choices. ");
}
}
while (menu < 6);
}
}
####Method####
public static void onLoad(AthletesID[] athId) throws IOException
{
DataInputStream istream;
int id, age;
String name, event;
double time;
istream= new DataInputStream(new FileInputStream("events.dat"));
try
{
for(int i=0;i<11;i++)
{
id = istream.readInt();
name = istream.readUTF();
age = istream.readInt();
event = istream.readUTF();
time = istream.readDouble();
athId.setathNum(id);
athId.setathName(name);
athId.setathAge(age);
athId.setathEvent(event);
athId.setathTime(time);
}
}
catch(IOException e)
{
System.err.println("File not opened");
}
finally
{
istream.close();
}
}
Many thanks for any help.
Regards Ne