/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely(ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(200); try { NbObjectOutputStream oos = new NbObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bos.close(); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt(0); throw new SafeException(exc); } oo.writeInt(bos.size()); oo.write(bos.toByteArray()); }
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely(ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(200); try { NbObjectOutputStream oos = new NbObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bos.close(); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt(0); throw new SafeException(exc); } oo.writeInt(bos.size()); oo.write(bos.toByteArray()); }
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely (ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream (200); try { NbObjectOutputStream oos = new NbObjectOutputStream (bos); oos.writeObject (obj); oos.flush (); bos.close (); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt (0); throw new SafeException (exc); } oo.writeInt (bos.size ()); oo.write (bos.toByteArray ()); }
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely (ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream (200); try { NbObjectOutputStream oos = new NbObjectOutputStream (bos); oos.writeObject (obj); oos.flush (); bos.close (); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt (0); throw new SafeException (exc); } oo.writeInt (bos.size ()); oo.write (bos.toByteArray ()); }
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely(ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(200); try { NbObjectOutputStream oos = new NbObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bos.close(); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt(0); throw new SafeException(exc); } oo.writeInt(bos.size()); oo.write(bos.toByteArray()); }