Package java.io

Examples of java.io.DataOutputStream


   * Constructors *
   *--------------*/

  public BinaryQueryResultWriter(OutputStream out) {
    assert out != null : "out must not be null";
    this.out = new DataOutputStream(out);
  }
View Full Code Here


    */
   public JBossBytesMessage(long messageID)
   {
      super(messageID);
      baos = new ByteArrayOutputStream();
      dos = new DataOutputStream(baos);
   }
View Full Code Here

                            byte[] payloadAsByteArray)
   {
      super(messageID, reliable, expiration, timestamp, priority, coreHeaders, payloadAsByteArray);           
     
      baos = new ByteArrayOutputStream();
      dos = new DataOutputStream(baos);
   }
View Full Code Here

      super(foreign, id);
     
      foreign.reset();
     
      baos = new ByteArrayOutputStream();
      dos = new DataOutputStream(baos);
                    
      byte[] buffer = new byte[1024];
      int n = foreign.readBytes(buffer);
      while (n != -1)
      {
View Full Code Here

      {
         //don't throw an exception
      }

      baos = new ByteArrayOutputStream();
      dos = new DataOutputStream(baos);
      this.setPayload(null);
      bais = null;
      dis = null;

      super.clearBody();
View Full Code Here

     * @param out the output stream
     * @exception IOException if an I/O error has occurred
     * @see #getMainAttributes
     */
    public void write(OutputStream out) throws IOException {
  DataOutputStream dos = new DataOutputStream(out);
  // Write out the main attributes for the manifest
  attr.writeMain(dos);
  // Now write out the pre-entry attributes
  Iterator it = entries.entrySet().iterator();
  while (it.hasNext()) {
      Map.Entry e = (Map.Entry)it.next();
            StringBuffer buffer = new StringBuffer("Name: ");
            String value = (String)e.getKey();
            if (value != null) {
                byte[] vb = value.getBytes("UTF8");
                value = new String(vb, 0, 0, vb.length);
            }
      buffer.append(value);
      buffer.append("\r\n");
            make72Safe(buffer);
            dos.writeBytes(buffer.toString());
      ((Attributes)e.getValue()).write(dos);
  }
  dos.flush();
    }
View Full Code Here

   public void write(Object obj, OutputStream out) throws IOException
   {         
      if (trace) { log.trace("Writing " + obj); }
     
      DataOutputStream dos;
     
      if (out instanceof DataOutputStream)
      {
         //For non HTTP transports - we should ALWAYS be passed a DataOutputStream
         //We do this by specifying socket wrapper classes on the locator uri
         dos = (DataOutputStream)out;
        
         if (trace) { log.trace("Stream is a DataOutputStream"); }
      }
      else
      {
         // Further sanity check
         if (out instanceof ObjectOutputStream)
         {
            throw new IllegalArgumentException("Invalid stream - are you sure you have " +
                                               "configured socket wrappers?");
         }
        
         // This would be the case for the HTTP transport for example. Wrap the stream.
        
         //FIXME - remoting should be fixed to allow socket wrappers to be specified for
         //all transports - not just socket
         //until then we have no choice but to create a wrapping stream on every invocation
         //for HTTP transport
         dos = new DataOutputStream(out);
        
         if (trace) { log.trace("Stream is NOT a DataOutputStream - must be using HTTP transport"); }
      }                 
     
      try
View Full Code Here

  
   protected void doTest(String s, int chunkSize) throws Exception
   {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
     
      DataOutputStream dos = new DataOutputStream(bos);
     
      SafeUTF su = new SafeUTF(chunkSize);
     
      su.safeWriteUTF(dos, s);
     
      dos.close();
     
      byte[] bytes = bos.toByteArray();
     
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
     
View Full Code Here

  
   public void testSafeWriteReadUTFTest2() throws Exception
   {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
     
      DataOutputStream dos = new DataOutputStream(bos);
     
      String s = "abcdefghijklmnopqrstuvwxyz";
     
      SafeUTF su = new SafeUTF(30);
     
      su.safeWriteUTF(dos, s);
     
      dos.close();
     
      byte[] bytes = bos.toByteArray();
     
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
     
View Full Code Here

        } catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException("Algorithm SHA-1 is not available", e);
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DigestOutputStream dos = new DigestOutputStream(baos, md);
        DataOutputStream das = new DataOutputStream(dos);

        StringBuilder sb = new StringBuilder();
        sb.append(methodName);
        sb.append(methodDescriptor);
        try {
            das.writeUTF(sb.toString());
        } catch (IOException e) {
            throw new IllegalStateException("Cannot write data for method '" + methodName + "'.", e);
        }
        try {
            das.flush();
        } catch (IOException e) {
            logger.warn("Cannot flush the stream", e);
        }
        try {
            das.close();
        } catch (IOException e) {
            logger.warn("Cannot flush the stream", e);
        }

        byte[] digest = md.digest();
View Full Code Here

TOP

Related Classes of java.io.DataOutputStream

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.