Example usage for java.io Writer write

List of usage examples for java.io Writer write

Introduction

In this page you can find the example usage for java.io Writer write.

Prototype

public void write(String str) throws IOException 

Source Link

Document

Writes a string.

Usage

From source file:com.aoyetech.fee.commons.utils.IOUtils.java

/**
 * Writes bytes from a <code>byte[]</code> to chars on a <code>Writer</code>
 * using the default character encoding of the platform.
 * <p>/*w  ww  . j  ava 2s  .  c  o  m*/
 * This method uses {@link String#String(byte[])}.
 * 
 * @param data the byte array to write, do not modify during output, null
 *            ignored
 * @param output the <code>Writer</code> to write to
 * @throws NullPointerException if output is null
 * @throws IOException if an I/O error occurs
 * @since Commons IO 1.1
 */
public static void write(final byte[] data, final Writer output) throws IOException {
    if (data != null) {
        output.write(new String(data));
    }
}

From source file:com.aoyetech.fee.commons.utils.IOUtils.java

/**
 * Writes chars from a <code>char[]</code> to a <code>Writer</code> using
 * the default character encoding of the platform.
 * /*from  w  w  w .  j a  va  2 s .c  o m*/
 * @param data the char array to write, do not modify during output, null
 *            ignored
 * @param output the <code>Writer</code> to write to
 * @throws NullPointerException if output is null
 * @throws IOException if an I/O error occurs
 * @since Commons IO 1.1
 */
public static void write(final char[] data, final Writer output) throws IOException {
    if (data != null) {
        output.write(data);
    }
}

From source file:com.aoyetech.fee.commons.utils.IOUtils.java

/**
 * Writes chars from a <code>String</code> to a <code>Writer</code>.
 * /*from   w  w w .  j a v a 2  s  .com*/
 * @param data the <code>String</code> to write, null ignored
 * @param output the <code>Writer</code> to write to
 * @throws NullPointerException if output is null
 * @throws IOException if an I/O error occurs
 * @since Commons IO 1.1
 */
public static void write(final String data, final Writer output) throws IOException {
    if (data != null) {
        output.write(data);
    }
}

From source file:com.aoyetech.fee.commons.utils.IOUtils.java

/**
 * Writes chars from a <code>StringBuffer</code> to a <code>Writer</code>.
 * //  w  w w  . j ava  2 s.c  om
 * @param data the <code>StringBuffer</code> to write, null ignored
 * @param output the <code>Writer</code> to write to
 * @throws NullPointerException if output is null
 * @throws IOException if an I/O error occurs
 * @since Commons IO 1.1
 */
public static void write(final StringBuffer data, final Writer output) throws IOException {
    if (data != null) {
        output.write(data.toString());
    }
}

From source file:com.intel.cosbench.exporter.ScriptsLogExporter.java

private void exportStageLog(Writer writer, StageInfo stage) throws IOException {
    writer.write("=========================");
    writer.write("=========================");
    writer.write(" stage: " + stage.getId() + ' ');
    writer.write("=========================");
    writer.write("=========================");
    writer.write('\n');
    String wsId = workload.getId() + stage.getId();
    doExportLog(writer, wsId);//from w  w  w  .  ja  v a  2s.c  o m
    writer.flush();
}

From source file:de.avanux.smartapplianceenabler.Application.java

private void writePidFile() {
    String pidFileName = System.getProperty("sae.pidfile");
    if (pidFileName != null) {
        String name = ManagementFactory.getRuntimeMXBean().getName();
        String pid = name.split("@")[0];
        try {/*from ww  w. ja v a 2 s.co m*/
            Writer pidFile = new FileWriter(pidFileName);
            pidFile.write(pid);
            pidFile.close();
            logger.info("PID " + pid + " written to " + pidFileName);
        } catch (IOException e) {
            logger.error("Error writing PID file " + pidFileName, e);
        }
    }
}

From source file:org.cbio.portal.pipelines.foundation.CnaDataWriter.java

@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
    // retrieve list of foundation cases from execution context
    final Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap");

    String stagingFile = outputDirectory + "data_CNA.txt";
    PassThroughLineAggregator aggr = new PassThroughLineAggregator();
    flatFileItemWriter.setLineAggregator(aggr);
    flatFileItemWriter.setHeaderCallback(new FlatFileHeaderCallback() {
        @Override//  ww  w .j  av  a2s . c  o  m
        public void writeHeader(Writer writer) throws IOException {
            writer.write(getHeader(fmiCaseTypeMap.keySet()));
        }
    });
    flatFileItemWriter.setResource(new FileSystemResource(stagingFile));
    flatFileItemWriter.open(executionContext);
}

From source file:com.controlj.green.bulktrend.trendserver.JSONTrendFormatter.java

public void setOutput(Writer out) throws IOException {
    super.setOutput(out);
    out.write("[");
}

From source file:org.cbio.portal.pipelines.foundation.ClinicalDataWriter.java

@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
    String stagingFile = outputDirectory + "data_clinical.txt";

    PassThroughLineAggregator aggr = new PassThroughLineAggregator();
    flatFileItemWriter.setLineAggregator(aggr);
    flatFileItemWriter.setHeaderCallback(new FlatFileHeaderCallback() {
        @Override/*w  ww .  j  a v  a  2 s  .  c om*/
        public void writeHeader(Writer writer) throws IOException {
            writer.write(getHeader());
        }
    });
    flatFileItemWriter.setResource(new FileSystemResource(stagingFile));
    flatFileItemWriter.open(executionContext);
}

From source file:com.cloudera.oryx.als.serving.web.EstimateForAnonymousServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

    CharSequence pathInfo = request.getPathInfo();
    if (pathInfo == null) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path");
        return;// www  . j  a  va  2 s.c  o m
    }
    Iterator<String> pathComponents = SLASH.split(pathInfo).iterator();
    String toItemID;
    Pair<String[], float[]> itemIDsAndValue;
    try {
        toItemID = pathComponents.next();
        itemIDsAndValue = RecommendToAnonymousServlet.parseItemValuePairs(pathComponents);
    } catch (NoSuchElementException nsee) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString());
        return;
    }

    if (itemIDsAndValue.getFirst().length == 0) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No items");
        return;
    }

    String[] itemIDs = itemIDsAndValue.getFirst();
    unescapeSlashHack(itemIDs);
    float[] values = itemIDsAndValue.getSecond();

    OryxRecommender recommender = getRecommender();
    try {
        float estimate = recommender.estimateForAnonymous(toItemID, itemIDs, values);
        Writer out = response.getWriter();
        out.write(Float.toString(estimate));
        out.write('\n');
    } catch (NotReadyException nre) {
        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString());
    } catch (NoSuchItemException nsie) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, nsie.toString());
    }
}