ok so i have a project for school, and i finished so the teacher wants it to read for a .dat the parameters for the java class here is what i got:
public void cargarCurso(){
try{
BufferedReader fileIn = new BufferedReader(
new FileReader("c:/cursoSem2.dat"));
String dataRenglon = fileIn.readLine();
while(dataRenglon !=null){
StringTokenizer stknzr = new StringTokenizer(dataRenglon,"_");
String clave = stknzr.nextToken();
String nombre = stknzr.nextToken();
String tipo = stknzr.nextToken();
String dni = stknzr.nextToken();
String despacho = stknzr.nextToken();
String departamento = stknzr.nextToken();
String dia = stknzr.nextToken();
String hora = stknzr.nextToken();
if(clave.charAt(0)=='P'){
Profesor profesor = new Profesor(
nombre,dni,despacho,departamento);
curso.addProfessor(profesor);
}else if(clave.charAt(0)=='A'){
Asignatura asignatura = new Asignatura(
nombre,tipo);
curso.addAsignatura(asignatura);
}else if(clave.charAt(0)=='H'){
Horarios horario = new Horarios(
dia,hora);
curso.addHorario(horario);
}dataRenglon = fileIn.readLine();
}
}catch(FileNotFoundException fnf){
System.err.println("Archivo no encontrado");
}catch(IOException ioe){
System.out.println("Error de lectura");
}
}
but is says at the end No such element exception
this is the information in the dat:
P_Erica Magano del Rio_EMR123_Contabilidad_C1
P_Gustavo_GCC123_Informatica_C2
P_Rosa_RMP123_Informatica_O1
P_Olmos Trejo_OMP123_Informatica_P1
P_Salvador Valerio_SVV123_Informatica_D1
P_Alex vargaz_PMP123_Informatica_P2
A_Contabilidad_Teorico
A_Calculo_Practico
A_OAC_Teorico
A_Programacion I_Practico
A_Diseno Interfaces_Practico
A_Diseno Web_Ambas
H_Lunes,Miercoles_7-9
H_Lunes,Miercoles_9-11
H_Martes,Jueves_7-9
H_Lunes,Miercoles_11-1
H_Martes,Jueves_9-11
H_Martes,Jueves_11-1
sorry it's in spanish but clave = code that will tell it if it's a P - Professor
A-Class and H-Schedule and each class has diferent parameters so i dont know if thats allowed for the string tokenizer and external reading, thanks for any help
(: