Package java.io

Examples of java.io.ByteArrayOutputStream$Cell


        // if a WSDL was found
        if (wsdlElement != null) {
            OMNamespace wsdlNamespace = wsdlElement.getNamespace();

            // serialize and create an input stream to read WSDL
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                if (trace()) trace.info("Serializing wsdlElement found to build an Axis2 service");
                wsdlElement.serialize(baos);
                wsdlInputStream = new ByteArrayInputStream(baos.toByteArray());
            } catch (XMLStreamException e) {
                handleException("Error converting to a StreamSource", e);
            }

            if (wsdlInputStream != null) {
View Full Code Here


  public static byte[] readStream(InputStream stream) {
    if(stream == null) {
      throw new IllegalArgumentException("null 'stream' arg passed in method call.");
    }
   
    ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
    byte[] buffer = new byte[256];
    int readCount = 0;
   
    try {
      while((readCount = stream.read(buffer)) != -1) {
        outBuffer.write(buffer, 0, readCount);
      }
    } catch (IOException e) {
      throw new IllegalStateException("Error reading stream.", e);
    }   
   
    return outBuffer.toByteArray();
  }
View Full Code Here

                    synLog.traceOrDebug("Storing the response for the message with ID : " +
                        synCtx.getMessageID() + " with request hash ID : " +
                        cachedObj.getRequestHash() + " in the cache : " + cacheKey);
                }

                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                try {
                    MessageHelper.cloneSOAPEnvelope(synCtx.getEnvelope()).serialize(outStream);
                    cachedObj.setResponseEnvelope(outStream.toByteArray());
                } catch (XMLStreamException e) {
                    handleException("Unable to set the response to the Cache", e, synCtx);
                }

                /* this is not required yet, can commented this for perf improvements
View Full Code Here

                String szFormat = vFormat.toString();
                if (szFormat == this.szCaptureFormat) {
                    break;
                }
            }
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream dos = new DataOutputStream(baos);
            dos.writeInt(nSource);
            dos.writeInt(nCapture);
            dos.writeInt(this.nCurrentHeight);
            dos.writeInt(this.nCurrentWidth);
            dos.flush();
            baos.flush();
            byte[] bRes = baos.toByteArray();
            dos = null;
            baos = null;
            rs.addRecord(bRes, 0, bRes.length);
            bRes = null;
            rs.closeRecordStore();
View Full Code Here

  public GZIPResponseStream(HttpServletResponse response) throws IOException {
    super();
    closed = false;
    this.response = response;
    this.output = response.getOutputStream();
    baos = new ByteArrayOutputStream();
    gzipstream = new GZIPOutputStream(baos);
  }
View Full Code Here

        static final byte VALUE       = 3;
       

        public byte[] objectToByteBuffer(Object obj) throws Exception {

            ByteArrayOutputStream out_stream=new ByteArrayOutputStream(35);
            DataOutputStream out=new DataOutputStream(out_stream);
            try {
                if(obj == null) {
                    out_stream.write(NULL);
                    out_stream.flush();
                    return out_stream.toByteArray();
                }
                if(obj instanceof MethodCall) {
                    out.writeByte(METHOD_CALL);
                    MethodCall call=(MethodCall)obj;
                    out.writeShort(call.getId());
                    Object[] args=call.getArgs();
                    if(args == null || args.length == 0) {
                        out.writeShort(0);
                    }
                    else {
                        out.writeShort(args.length);
                        for(int i=0; i < args.length; i++) {
                            Util.objectToStream(args[i], out);
                        }
                    }
                }
                else if(obj instanceof Cache.Value) {
                    Cache.Value value=(Cache.Value)obj;
                    out.writeByte(VALUE);
                    out.writeLong(value.getTimeout());
                    Util.objectToStream(value.getValue(), out);
                }
                else {
                    out.writeByte(OBJ);
                    Util.objectToStream(obj, out);
                }
                out.flush();
                return out_stream.toByteArray();
            }
            finally {
                Util.close(out);
            }
        }
View Full Code Here

    socket.setTcpNoDelay(params.TcpNoDelay);
    socket.setSoTimeout(params.SoTimeout);
    if (params.SoLinger >= 0)
      socket.setSoLinger(true, params.SoLinger);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputStream os = socket.getOutputStream();
    InputStream is = socket.getInputStream();

    // Writes the Joram magic number
    baos.write(MetaData.joramMagic);
    // Writes the current date
    StreamUtil.writeTo(System.currentTimeMillis(), baos);

    // Writes the user identity
    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG, " -> write identity = " + identity);
    Identity.write(identity, baos);

    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG, " -> write key = " + key);
    StreamUtil.writeTo(key, baos);

    if (key == -1) {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, " -> connection opened, initializes new connection");
      StreamUtil.writeTo(reconnectTimeout, baos);
      baos.writeTo(os);
      os.flush();

      int len = StreamUtil.readIntFrom(is);
      long dt = StreamUtil.readLongFrom(is);
      if (dt > clockSynchroThreshold)
        logger.log(BasicLevel.WARN, " -> bad clock synchronization between client and server: " + dt);

      int res = StreamUtil.readIntFrom(is);
      if (res > 0) {
        String info = StreamUtil.readStringFrom(is);
        throwSecurityError(info);
      }

      key = StreamUtil.readIntFrom(is);
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, " -> key = " + identity.getUserName() + ',' + key);
      connection = new ReliableTcpConnection(timer);
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, " -> init reliable connection");
    } else {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, " -> reinitializes connection " + identity + ',' + key);
      baos.writeTo(os);
      os.flush();

      int len = StreamUtil.readIntFrom(is);
      int res = StreamUtil.readIntFrom(is);
      if (logger.isLoggable(BasicLevel.DEBUG))
View Full Code Here

          if (msg.not.expiration > 0)
            msg.not.expiration -= time;

          // Writes a serializable object to this output stream.
          if (compressedFlows) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            GZIPOutputStream gzipos = new GZIPOutputStream(baos);
           
            oos = new ObjectOutputStream(gzipos);
            oos.writeObject(msg.not);

            // Be careful, the reset writes a TC_RESET byte
            oos.reset();
            // The OOS flush call the flush of this output stream.
            oos.flush();
            gzipos.finish();
            gzipos.flush();
           
            if (getLogger().isLoggable(BasicLevel.DEBUG))
              getLogger().log(BasicLevel.DEBUG, "writeNotification - size=" + baos.size());

            writeInt(baos.size());
            baos.writeTo(this);
           
            flush();
           
            oos = null;
          } else {
View Full Code Here

      return log;
    }
   
    Context() {
      log = new Hashtable(15);
      bos = new ByteArrayOutputStream(256);
    }
View Full Code Here

  }

  public void save(Serializable obj,
                   String dirName, String name,
                   boolean first) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(obj);
    oos.flush();
    saveByteArray(bos.toByteArray(), dirName, name);
  }
View Full Code Here

TOP

Related Classes of java.io.ByteArrayOutputStream$Cell

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.