Package ManejoArchivos

Source Code of ManejoArchivos.ArchivoCurso

/*
Clase encargada del manejo del archivo de texto que contiene la información de los cursos
que van a ser dictados y requieren ser programados.
Autor: Fernando Alva
*/

package ManejoArchivos;

import GeneracionHorarios.Curso;

import GeneracionHorarios.Profesor;
import ManejoBD.ProfesorBD;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;

public class ArchivoCurso {
    private BufferedReader lector;
   
    public ArchivoCurso(String ruta) throws FileNotFoundException {
        lector = new BufferedReader(new FileReader(ruta));
    }

    public Curso leer() throws IOException, SQLException {
        String lineaCurso = lector.readLine();
        if (lineaCurso==null)
            throw new IOException();
        String [] datosCurso = lineaCurso.split(",");
        Profesor profesor = ProfesorBD.buscarProfesor(datosCurso[7]);
        return new Curso (-1,datosCurso[0],datosCurso[1],datosCurso[2],Integer.parseInt(datosCurso[3]),
                          Integer.parseInt(datosCurso[4]),Integer.parseInt(datosCurso[5]),Integer.parseInt(datosCurso[6]),profesor);
    }
   
    public void finLectura(){
        try {
            lector.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
TOP

Related Classes of ManejoArchivos.ArchivoCurso

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.