Package java.io

Examples of java.io.ObjectOutputStream


    }

    private static void bulkOut(ObjectOutput out, Sequence<Item> entity, boolean remotePaing)
            throws IOException {
        final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
        final ObjectOutputStream objOut = new ObjectOutputStream(bufOut);
        final XQEventEncoder encoder = new XQEventEncoder(objOut);
        if(remotePaing) {
            encoder.setRemotePaging(true);
        }
        try {
            encoder.emit(entity);
            objOut.flush();
        } catch (XQueryException xqe) {
            throw new IllegalStateException("failed encoding", xqe);
        } catch (Throwable e) {
            LOG.fatal(e);
            throw new IllegalStateException("failed encoding", e);
View Full Code Here


            }
            result[actsize++] = e;
        }
        final FastMultiByteArrayOutputStream bos = new FastMultiByteArrayOutputStream();
        final OutputStream os = compress ? new LZFOutputStream(bos) : bos;
        final ObjectOutputStream oos;
        try {
            oos = new ObjectOutputStream(os);
            oos.writeInt(actsize);
            for(int i = 0; i < actsize; i++) {
                oos.writeObject(result[i]);
                result[i] = null;
            }
            oos.flush();
        } catch (IOException e) {
            throw new RemoteException("failed to serialize", e);
        }
        final byte[] ary = bos.toByteArray_clear();
        try {
            oos.close();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        return ary;
    }
View Full Code Here

        if(file.canWrite()) {
            throw new IllegalStateException("Does not have write permission for "
                    + file.getAbsolutePath());
        }
        try {
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
            oos.writeObject(this);
            oos.flush();
            oos.close();
        } catch (FileNotFoundException fe) {
            throw new DbException(fe);
        } catch (IOException ioe) {
            throw new DbException(ioe);
        }
View Full Code Here

   /**
    * Synchronizing this prevents multiple threads from sending messages at the same
    * time which corrupts the socket.
     */
    public synchronized boolean sendObject(Object object) {
        ObjectOutputStream writer = null;
        try {
            writer = new ObjectOutputStream(socket.getOutputStream());
        }
        catch (IOException e) {
            logger.error("Exception when creating writer sending object: " + object, e);
            return false;
        }

        try {
            writer.reset();
            writer.flush();
            writer.writeObject(object);
            writer.flush();

            return true;
        }
        catch (Exception e) {
            logger.error("Exception when sending object: " + object, e);
View Full Code Here

  public static void serializeObject(Serializer serializer, Object object) throws IOException
  {
    try {

      ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
      ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutputStream);
      objectOutput.writeObject(object);
      objectOutput.flush();
      byteOutputStream.close();
      serializer.write(byteOutputStream.size());
      serializer.write(':');
      byteOutputStream.writeTo(serializer.getOutput());
    } catch (InvalidClassException e) {
View Full Code Here

         */
        private void incrPipedOutReaccessable(final ObjectOutputStream out) throws IOException {
            assert (_reaccessable);
            final FastMultiByteArrayOutputStream bufOut = new FastMultiByteArrayOutputStream(BUFFERING_BLOCK_SIZE);
            final TeeOutputStream tee = new TeeOutputStream(out, bufOut);
            final ObjectOutputStream objectOut = new NoHeaderObjectOutputStream(tee);
            final XQEventDecoder decoder = _decoder;
            decoder.redirectTo(objectOut);
            decoder.close();
            objectOut.flush();

            // Because input of decoder fully read, this section required for re-object serialization, etc.
            final byte[][] buf = bufOut.toMultiByteArray();
            final int bufTotalSize = bufOut.size();
            bufOut.clear();
View Full Code Here

            this._decoder = new XQEventDecoder(objInput); // replace old Decoder with fresh Decoder
        }

        private void incrBulkOut(final ObjectOutput out) throws IOException {
            final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
            final ObjectOutputStream objectOut = new ObjectOutputStream(bufOut);
            final XQEventDecoder decoder = _decoder;
            decoder.redirectTo(objectOut);
            decoder.close();
            objectOut.flush();
            final byte[] buf = bufOut.toByteArray();
            bufOut.clear();

            // Because input of decoder fully read, this section required for re-object serialization, etc.
            if(_reaccessable) {
View Full Code Here

    }

    public synchronized void doEncode() throws IOException {
        if(encodedSequence != null) {
            final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
            final ObjectOutputStream objOut = new ObjectOutputStream(bufOut);
            final XQEventEncoder encoder = new XQEventEncoder(objOut);
            try {
                encoder.emit(actualSequence);
                objOut.flush();
            } catch (XQueryException xqe) {
                throw new IOException(PrintUtils.prettyPrintStackTrace(xqe));
            } catch (Throwable e) {
                LOG.fatal(e);
                throw new IOException(PrintUtils.prettyPrintStackTrace(e));
View Full Code Here

     * @param graphicsSaveFile
     */
    public void writeGraphics(String graphicsSaveFile) throws IOException {

        FileOutputStream ostream = new FileOutputStream(graphicsSaveFile);
        ObjectOutputStream objectstream = new ObjectOutputStream(ostream);
        writeGraphics(objectstream);
        objectstream.close();
    }
View Full Code Here

  private boolean isKeySerializable(final ResourceKey key)
  {
    try
    {
      final ObjectOutputStream oout = new ObjectOutputStream(new NullOutputStream());
      oout.writeObject(key);
      oout.close();
      return true;
    }
    catch (Exception e)
    {
      return false;
View Full Code Here

TOP

Related Classes of java.io.ObjectOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.