Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Ficheiro;
- import java.io.*;
- import Registos.*;
- public class FicheiroEvento_Joel {
- public static final String NOME_FICHEIRO = "RegistoEvento.bin";
- public RegistoEvento ler() {
- RegistoEvento re;
- try {
- ObjectInputStream in = new ObjectInputStream(
- new FileInputStream(NOME_FICHEIRO));
- try {
- re = (RegistoEvento) in.readObject();
- } finally {
- in.close();
- }
- return re;
- } catch (IOException | ClassNotFoundException ex) {
- return null;
- }
- }
- public boolean guardar(RegistoEvento re) {
- try {
- ObjectOutputStream out = new ObjectOutputStream(
- new FileOutputStream(NOME_FICHEIRO));
- try {
- out.writeObject(re);
- } finally {
- out.close();
- }
- return true;
- } catch (IOException ex) {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement