/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ManejoArchivos;
import GeneracionHorarios.EstructuraProfesor;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
*
* @author Fernando
*/
public class ArchivoEstProfesor {
private String rutaArch;
public ArchivoEstProfesor(String rutaArch){
this.rutaArch = rutaArch;
}
public EstructuraProfesor leer() throws FileNotFoundException, IOException, ClassNotFoundException{
ObjectInputStream lector = new ObjectInputStream(new BufferedInputStream(new FileInputStream(rutaArch)));
EstructuraProfesor est = null;
while (true){
try {
est = (EstructuraProfesor) lector.readObject();
} catch (EOFException ex) {
break;
}
}
lector.close();
return est;
}
public void guardar(EstructuraProfesor est) throws FileNotFoundException, IOException{
ObjectOutputStream escritor = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(rutaArch)));
escritor.writeObject(est);
escritor.close();
}
}