code: public static <T extends Serializable> T deserialize(byte[] bytes, boolean compressed) throws IOException, ClassNotFoundException {
          requireNonNull(bytes);
  
          try (ByteArrayInputStream i = new ByteArrayInputStream(bytes);
               ObjectInputStream ois = new ObjectInputStream(compressed ? new GZIPInputStream(i) : i)) {
              return (T) ois.readObject();
          }
      }
docs: Utility for returning a Serializable object from a byte array. Only use the {@code compressed} option if the
  data was originally compresses when using the {@link Serializables#serialize(Serializable, boolean)} method.