public static void ler_Contracto() {
        // Wrap all in a try/catch block to trap I/O errors.
        try {
            // Open file to read from, named SavedObj.dat.
            FileInputStream saveFile = new FileInputStream("Contracto.dat");
            
            FileInputStream saveFileH = new FileInputStream("Contracto_Hist.dat");

            // Create an ObjectInputStream to get objects from save file.
            ObjectInputStream save = new ObjectInputStream(saveFile);
            
            ObjectInputStream saveH = new ObjectInputStream(saveFileH);

            // Now we do the restore.
            // readObject() returns a generic Object, we cast those back
            // into their original class type.
            // For primitive types, use the corresponding reference class.
            list = (ArrayList<Contracto>) save.readObject();
            long x = save.readLong();
            
            Contracto.setId_aux_contracto(x);

            historico = (ArrayList<Contracto>) saveH.readObject();

            // Close the file.
            save.close(); // This also closes saveFile.
        } catch (FileNotFoundException ex) {
            System.out.println("Ficheiro Contracto.dat nao encontrado!");
        } catch (Exception exc) {
            exc.printStackTrace(); // If there was an error, print the info.
        }
    }