Package com.ibm.commons.util.io

Examples of com.ibm.commons.util.io.ByteStreamCache


  }

  protected byte[] toByteArray(Object object) throws CredentialStoreException {
    try {
      if(object!=null) {
        ByteStreamCache bs = new ByteStreamCache(1024);
        ObjectOutputStream os = new ObjectOutputStream(bs.getOutputStream());
        try {
          os.writeObject(object);
          return bs.toByteArray();
        } finally {
          os.close();
        }
      }
      return null;
View Full Code Here


    try {
      // When no length is specified, the HTTP client core forces Transfert-Encoding: chunked
      // The code bellow shows a workaround, although we should avoid that
      if(false) {
        if(length<0) {
          ByteStreamCache bs = new ByteStreamCache();
          bs.copyFrom(request.getInputStream());
          HttpEntity payloadEntity = new InputStreamEntity(bs.getInputStream(), bs.getLength());
          ((HttpEntityEnclosingRequest) method).setEntity(payloadEntity);
          return method;
        }
      }
      // Regular code
View Full Code Here

       
        JarEntry entry = new JarEntry( entryName );
        entry.setMethod( ZipEntry.DEFLATED );
       
        CRC32 checksumCalculator= new CRC32();
        ByteStreamCache bsc = new ByteStreamCache();
        entry.setSize( StreamUtil.copyStream( is, bsc.getOutputStream() ));
        checksumCalculator.update( bsc.toByteArray() );
        entry.setCrc(checksumCalculator.getValue());
       
        jarOS.putNextEntry( entry );
        //Now that we have the correct size, we can copy it to the jar stream
        StreamUtil.copyStream( bsc.getInputStream(), jarOS );
       
        entriesSet.add( entryName );
    }
View Full Code Here

  }
 
  private void emit(HttpServletResponse resp, String text, String contentType) throws IOException {
    resp.setStatus(200);
    resp.setContentType(contentType);
    ByteStreamCache bs = new ByteStreamCache();
    InputStream is = new ReaderInputStream(new StringReader(text),"utf-8");
    bs.copyFrom(is);
    resp.setContentLength((int)bs.getLength());
    OutputStream os = resp.getOutputStream();
    bs.copyTo(os);
    os.flush();
  }
View Full Code Here

TOP

Related Classes of com.ibm.commons.util.io.ByteStreamCache

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.