Package java.io

Examples of java.io.ByteArrayOutputStream.writeTo()


      final JavaClass clazz = (JavaClass)classes.nextElement();
      final String className = clazz.getClassName().replace('.','/');
      jos.putNextEntry(new JarEntry(className+".class"));
      final ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
      clazz.dump(out); // dump() closes it's output stream
      out.writeTo(jos);
  }
  jos.close();
    }

    /**
 
View Full Code Here


  {
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    data.serialize(new Serializer(context, byteStream));
    writeInt(output, byteStream.size());
    output.write(':');
    byteStream.writeTo(output);

  }

  /**
 
View Full Code Here

      if (null!=buos) {
        if (null!=gzos) { //Content-Encoding: gzip
          gzos.finish();
          response.addHeader(HeaderBase.CONTENT_ENCODING, "gzip");
          response.setContentLength(baos.size());
          baos.writeTo(os);
        } else { // Initially unknown content length.
          if(totalBytesRead > 0) {
            response.setContentLength(totalBytesRead);
            baos.writeTo(os);
          }
View Full Code Here

          response.setContentLength(baos.size());
          baos.writeTo(os);
        } else { // Initially unknown content length.
          if(totalBytesRead > 0) {
            response.setContentLength(totalBytesRead);
            baos.writeTo(os);
          }
        }
      }
      is.close();
    }
View Full Code Here

        COSDictionary streamDict = new COSDictionary();
        streamDict.setItem(COSName.LENGTH, new COSInteger(baos.size()));
        COSStream output = new COSStream(streamDict, pdfDocument.getDocument().getScratchFile());
        output.setFilters(stream.getFilters());
        OutputStream os = output.createUnfilteredStream();
        baos.writeTo(os);
        os.close();

        return output;
    }
View Full Code Here

                // TODO: Should this be application/xml? See JCR-1621
                httpResponse.setContentType(
                        "text/xml; charset=" + SerializingContentHandler.ENCODING);
                httpResponse.setContentLength(out.size());
                out.writeTo(httpResponse.getOutputStream());
            } catch (ParserConfigurationException e) {
                log.error(e.getMessage());
                throw new IOException(e.getMessage());
            } catch (TransformerException e) {
                log.error(e.getMessage());
View Full Code Here

        } else {
            if (inmem) {
                if (currentStream instanceof ByteArrayOutputStream) {
                    ByteArrayOutputStream byteOut = (ByteArrayOutputStream) currentStream;
                    if (copyOldContent && byteOut.size() > 0) {
                        byteOut.writeTo(out);
                    }
                } else if (currentStream instanceof PipedOutputStream) {
                    PipedOutputStream pipeOut = (PipedOutputStream) currentStream;
                    IOUtils.copyAndCloseInput(new PipedInputStream(pipeOut), out);
                } else {
View Full Code Here

            } else {
                tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false);
            }
           
            currentStream = createOutputStream(tempFile);
            bout.writeTo(currentStream);
            inmem = false;
            streamList.add(currentStream);
        } catch (Exception ex) {
            //Could be IOException or SecurityException or other issues.
            //Don't care what, just keep it in memory.
View Full Code Here

        } else {
            if (inmem) {
                if (currentStream instanceof ByteArrayOutputStream) {
                    ByteArrayOutputStream byteOut = (ByteArrayOutputStream) currentStream;
                    if (copyOldContent && byteOut.size() > 0) {
                        byteOut.writeTo(out);
                    }
                } else if (currentStream instanceof PipedOutputStream) {
                    PipedOutputStream pipeOut = (PipedOutputStream) currentStream;
                    IOUtils.copyAndCloseInput(new PipedInputStream(pipeOut), out);
                } else {
View Full Code Here

            } else {
                tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false);
            }
           
            currentStream = new BufferedOutputStream(new FileOutputStream(tempFile));
            bout.writeTo(currentStream);
            inmem = false;
            streamList.add(currentStream);
        } catch (Exception ex) {
            //Could be IOException or SecurityException or other issues.
            //Don't care what, just keep it in memory.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.