/** * 读出对象。 * * @param is * @return * @throws StreamCorruptedException * @throws IOException * @throws ClassNotFoundException */ public static Object readObject(InputStream is) throws StreamCorruptedException, IOException, ClassNotFoundException { ObjectInputStream ois = null; try { ois = new ObjectInputStream(is); return ois.readObject(); } finally { IOKit.closeQuietly(ois); IOKit.closeQuietly(is); } }
/** * 写入对象。 * * @param object * @param os * @throws IOException */ public static void writeObject(final Serializable object, final OutputStream os) throws IOException { ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(os); oos.writeObject(object); } finally { IOKit.closeQuietly(oos); IOKit.closeQuietly(os); } }