Package org.apache.commons.io.output

Examples of org.apache.commons.io.output.WriterOutputStream


   * into a character streams. If both {@link Writer} arguments are the same object
   * the streams will be combined. 
   */
  public void decodeStreams(List<IEvent> events, Writer sysout, Writer syserr) {
    int lineBuffer = 160;
    WriterOutputStream stdout = new WriterOutputStream(sysout, getCharset(), lineBuffer, true);
    WriterOutputStream stderr = new WriterOutputStream(syserr, getCharset(), lineBuffer, true);
    for (IEvent evt : events) {
      try {
        switch (evt.getType()) {
          case APPEND_STDOUT:
            if (sysout != null) {
              stdout.write(((AppendStdOutEvent) evt).getChunk());
            }
            break;

          case APPEND_STDERR:
            if (syserr != null) {
              stderr.write(((AppendStdErrEvent) evt).getChunk());
            }
            break;
        }
      } catch (IOException e) {
        // Ignore.
      }
    }

    try {
      stdout.flush();
      stderr.flush();
    } catch (IOException e) {
      // Ignore.
    }
  }
View Full Code Here


    final JsonArray output = new JsonArray();
    final SlaveInfo slave = e.getSlave();
    int lineBuffer = 160;
    final StringWriter out = new StringWriter();
    final StringWriter err = new StringWriter();
    WriterOutputStream stdout = new WriterOutputStream(out, slave.getCharset(), lineBuffer, false);
    WriterOutputStream stderr = new WriterOutputStream(err, slave.getCharset(), lineBuffer, false);
    for (IEvent evt : e.getEventStream()) {
      try {
        switch (evt.getType()) {
          case TEST_STARTED:
          case TEST_FINISHED:
            flushBoth(output, out, err, stdout, stderr);
            JsonObject marker = new JsonObject();
            marker.addProperty("test", ((AbstractEventWithDescription) evt).getDescription().getDisplayName());
            marker.addProperty("event", evt.getType().toString());
            output.add(marker);
            break;

          case APPEND_STDOUT:
            flush("err", output, stderr, err);
            stdout.write(((AppendStdOutEvent) evt).getChunk());
            break;

          case APPEND_STDERR:
            flush("out", output, stdout, out);
            stderr.write(((AppendStdErrEvent) evt).getChunk());
            break;
        }
      } catch (IOException ex) {
        // Ignore.
      }
View Full Code Here

  }

  @Subscribe
  public void onSuiteStart(AggregatedSuiteStartedEvent e) throws IOException {
    final Charset charset = e.getSlave().getCharset();
    outStream = new WriterOutputStream(outWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);
    errStream = new WriterOutputStream(errWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);

    if (showSuiteSummary && isPassthrough()) {
      SuiteStartedEvent evt = e.getSuiteStartedEvent();
      emitSuiteStart(evt.getDescription(), evt.getStartTimestamp());
    }
View Full Code Here

  }

  @Subscribe
  public void onSuiteStart(AggregatedSuiteStartedEvent e) throws IOException {
    final Charset charset = e.getSlave().getCharset();
    outStream = new WriterOutputStream(outWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);
    errStream = new WriterOutputStream(errWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);

    if (showSuiteSummary && isPassthrough()) {
      SuiteStartedEvent evt = e.getSuiteStartedEvent();
      emitSuiteStart(evt.getDescription(), evt.getStartTimestamp());
    }
View Full Code Here

  }

  @Subscribe
  public void onSuiteStart(AggregatedSuiteStartedEvent e) throws IOException {
    final Charset charset = e.getSlave().getCharset();
    outStream = new WriterOutputStream(outWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);
    errStream = new WriterOutputStream(errWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);

    if (showSuiteSummary && isPassthrough()) {
      SuiteStartedEvent evt = e.getSuiteStartedEvent();
      emitSuiteStart(evt.getDescription(), evt.getStartTimestamp());
    }
View Full Code Here

   * into a character streams. If both {@link Writer} arguments are the same object
   * the streams will be combined. 
   */
  public void decodeStreams(List<IEvent> events, Writer sysout, Writer syserr) throws IOException {
    int lineBuffer = 160;
    WriterOutputStream stdout = new WriterOutputStream(sysout, getCharset(), lineBuffer, true);
    WriterOutputStream stderr = new WriterOutputStream(syserr, getCharset(), lineBuffer, true);
    for (IEvent evt : events) {
      switch (evt.getType()) {
        case APPEND_STDOUT:
          if (sysout != null) {
            ((IStreamEvent) evt).copyTo(stdout);
          }
          break;

        case APPEND_STDERR:
          if (syserr != null) {
            ((IStreamEvent) evt).copyTo(stderr);
          }
          break;
      }
    }

    stdout.flush();
    stderr.flush();
  }
View Full Code Here

    }

    private Document writeToXmlWithValidation(StreamingOutput output)
            throws IOException, SAXException {
        StringBuilderWriter sbWriter = new StringBuilderWriter();
        WriterOutputStream writerOutputStream =
                new WriterOutputStream(sbWriter);
        output.write(writerOutputStream);
        writerOutputStream.close();
        String xml = sbWriter.toString();
        assertValidTMX(xml);
        DocumentBuilder controlParser = XMLUnit.newControlParser();
        controlParser.setEntityResolver(new TmxDtdResolver());
        Document doc =
View Full Code Here

            writer.writeStartElement("data");
            writer.writeAttribute("id", "" + id);

            Base64InputStream base64EncodingIn = new Base64InputStream( data, true, PlanXMLConstants.BASE64_LINE_LENGTH, PlanXMLConstants.BASE64_LINE_BREAK);
           
            OutputStream out = new WriterOutputStream(new XMLStreamContentWriter(writer) , PlanXMLConstants.ENCODING);
            // read the binary data and encode it on the fly
            IOUtils.copy(base64EncodingIn, out);
            out.flush();
           
            // all data is written - end
            writer.writeEndElement();
            writer.writeEndDocument();
View Full Code Here

   * into a character streams. If both {@link Writer} arguments are the same object
   * the streams will be combined. 
   */
  public void decodeStreams(List<IEvent> events, Writer sysout, Writer syserr) {
    int lineBuffer = 160;
    WriterOutputStream stdout = new WriterOutputStream(sysout, getCharset(), lineBuffer, true);
    WriterOutputStream stderr = new WriterOutputStream(syserr, getCharset(), lineBuffer, true);
    for (IEvent evt : events) {
      try {
        switch (evt.getType()) {
          case APPEND_STDOUT:
            if (sysout != null) {
              stdout.write(((AppendStdOutEvent) evt).getChunk());
            }
            break;

          case APPEND_STDERR:
            if (syserr != null) {
              stderr.write(((AppendStdErrEvent) evt).getChunk());
            }
            break;
        }
      } catch (IOException e) {
        // Ignore.
      }
    }

    try {
      stdout.flush();
      stderr.flush();
    } catch (IOException e) {
      // Ignore.
    }
  }
View Full Code Here

            @Override
            public void run(Reader input, String inputUri, Writer output) throws ParseException {
                try {
                    sp.process(input, inputUri);
                } finally {
                    OutputStream outputStream = new WriterOutputStream(output, "UTF-8");
                    try {
                        Serializer serializer = Serializer.getInstance();
                        serializer.serialize(outputStream, graph, "text/turtle");
                    } finally {
                        IOUtils.closeQuietly(outputStream);
View Full Code Here

TOP

Related Classes of org.apache.commons.io.output.WriterOutputStream

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.