code: public static <T> T deSerializeFromDisk( File file, Class<T> adaptee ) throws Exception {
          try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
              long length = raf.length();
              // System.out.println(length + "/" + (int) length);
              byte[] bytes = new byte[(int) length];
              int read = raf.read(bytes);
              if (read != length) {
                  throw new IOException();
              }
              ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
              Object readObject = in.readObject();
              return adaptee.cast(readObject);
          }
      }
docs: Deserialize a file to a given object.
  
  @param file
  the file to read.
  @param adaptee
  the class to adapt to.
  @return the object.
  @throws Exception