Example usage for java.io PrintStream print

List of usage examples for java.io PrintStream print

Introduction

In this page you can find the example usage for java.io PrintStream print.

Prototype

public void print(Object obj) 

Source Link

Document

Prints an object.

Usage

From source file:de.juwimm.cms.model.EditionHbmDaoImpl.java

@Override
protected void handleShortLinksToXmlRecursive(Integer siteId, PrintStream out, EditionHbm edition)
        throws Exception {
    out.println("\t<shortLinks>");
    try {/*from   w w w . j  ava2 s.co m*/
        Collection shortLinkList = getShortLinkHbmDao().findAll(siteId);
        Iterator it = shortLinkList.iterator();
        while (it.hasNext()) {
            ShortLinkHbm shortLink = (ShortLinkHbm) it.next();
            out.print(shortLink.toXml(2));
        }
    } catch (Exception exe) {
        log.error("Error occured", exe);
    }
    out.println("\t</shortLinks>");

}

From source file:iristk.util.Record.java

/**
 * Saves the record in JSON format to a file. If the file already exists, the content in the file is overwritten with the new record data.
 * //from   www .ja v a  2 s. c o m
 * @param inputJSONfile The file the record data are stored in
 * @throws IOException
 */
public void toJSON(File inputJSONfile) throws IOException {
    //Without the if the method will throw a NullPointer when no parent is directly specified when creating the new file
    if (inputJSONfile.getParent() != null) {
        if (!inputJSONfile.getParentFile().exists()) {
            inputJSONfile.getParentFile().mkdirs();
        }
    }
    OutputStream out = new FileOutputStream(inputJSONfile);
    final PrintStream printStream = new PrintStream(out);
    printStream.print(toJSON().toString());
    printStream.close();
}

From source file:edu.cornell.med.icb.goby.modes.TallyBasesMode.java

private void writeHeader(final PrintStream output, final int windowSize) {
    final MutableString buffer = new MutableString();
    buffer.append("position");
    buffer.append('\t');
    buffer.append("referenceId");
    buffer.append('\t');
    for (int i = -windowSize; i < windowSize; i++) {
        buffer.append("position").append(i < 0 ? "" : '+').append(String.valueOf(i));
        buffer.append('\t');
    }//from  w ww  .j a v a  2s .  c o m
    buffer.append("foldChange");
    buffer.append('\t');
    buffer.append("countA");
    buffer.append('\t');
    buffer.append("countB");
    buffer.append('\t');
    buffer.append("sumA");
    buffer.append('\t');
    buffer.append("sumB");
    buffer.append('\n');
    output.print(buffer);
}

From source file:examples.ClassPropertyUsageAnalyzer.java

/**
 * Prints the data for a single class to the given stream. This will be a
 * single line in CSV.// w w w .  ja v a  2s .c  o  m
 *
 * @param out
 *            the output to write to
 * @param classRecord
 *            the class record to write
 * @param entityIdValue
 *            the item id that this class record belongs to
 */
private void printClassRecord(PrintStream out, ClassRecord classRecord, EntityIdValue entityIdValue) {
    printTerms(out, classRecord.itemDocument, entityIdValue, "\"" + getClassLabel(entityIdValue) + "\"");
    printImage(out, classRecord.itemDocument);

    out.print("," + classRecord.itemCount + "," + classRecord.subclassCount);

    printClassList(out, classRecord.superClasses);

    HashSet<EntityIdValue> superClasses = new HashSet<>();
    for (EntityIdValue superClass : classRecord.superClasses) {
        addSuperClasses(superClass, superClasses);
    }

    printClassList(out, superClasses);

    printRelatedProperties(out, classRecord);

    out.println("");
}

From source file:de.fosd.jdime.artifact.file.FileArtifact.java

/**
 * Outputs the contents represented by this {@link FileArtifact} and its children using the given
 * {@link PrintStream}./*from w  w  w .  j av a  2  s  . c  o m*/
 *
 * @param to
 *         the {@link PrintStream} to write to
 */
public void outputContent(PrintStream to) {

    if (isDirectory()) {
        getChildren().forEach(c -> {
            c.outputContent(to);
            to.println();
        });
    } else {
        to.print(getContent());
    }
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.sensitivity.SobolAnalysis.java

/**
 * Computes and displays the first- and total-order Sobol' sensitivites and
 * 50% bootstrap confidence intervals./*from  w  w  w  . j a v  a  2s .  co  m*/
 * 
 * @param output the output stream
 */
private void displaySimple(PrintStream output) {
    output.println("First-Order Effects");
    for (int j = 0; j < P; j++) {
        double[] a0 = new double[N];
        double[] a1 = new double[N];
        double[] a2 = new double[N];

        for (int i = 0; i < N; i++) {
            a0[i] = A[i];
            a1[i] = C_A[i][j];
            a2[i] = B[i];
        }

        double value = computeFirstOrder(a0, a1, a2, N);
        output.print(value < 0 ? 0.0 : value);

        if (j < P - 1) {
            output.print('\t');
        }
    }

    output.println();
    output.println("Total-Order Effects");
    for (int j = 0; j < P; j++) {
        double[] a0 = new double[N];
        double[] a1 = new double[N];
        double[] a2 = new double[N];

        for (int i = 0; i < N; i++) {
            a0[i] = A[i];
            a1[i] = C_A[i][j];
            a2[i] = B[i];
        }

        double value = computeTotalOrder(a0, a1, a2, N);
        output.print(value < 0 ? 0.0 : value);

        if (j < P - 1) {
            output.print('\t');
        }
    }

    output.println();
}

From source file:com.opengamma.analytics.example.coupledfokkerplank.CoupledFokkerPlankExample.java

public static void runCoupledFokkerPlank(PrintStream out) throws FileNotFoundException, IOException {
    final ExtendedCoupledFiniteDifference solver = new ExtendedCoupledFiniteDifference(0.5);
    final int tNodes = 50;
    final int xNodes = 150;

    final MeshingFunction timeMesh = new ExponentialMeshing(0, T, tNodes, 5.0);
    final MeshingFunction spaceMesh = new HyperbolicMeshing(LOWER.getLevel(), UPPER.getLevel(), SPOT, xNodes,
            0.01);/*from   w  w  w  .  j  a v a2 s .  co  m*/

    final double[] timeGrid = new double[tNodes];
    for (int n = 0; n < tNodes; n++) {
        timeGrid[n] = timeMesh.evaluate(n);
    }

    final double[] spaceGrid = new double[xNodes];
    for (int i = 0; i < xNodes; i++) {
        spaceGrid[i] = spaceMesh.evaluate(i);
    }
    final PDEGrid1D grid = new PDEGrid1D(timeGrid, spaceGrid);

    final PDEResults1D[] res = solver.solve(DATA1, DATA2, grid, LOWER, UPPER, LOWER, UPPER, null);
    final PDEFullResults1D res1 = (PDEFullResults1D) res[0];
    final PDEFullResults1D res2 = (PDEFullResults1D) res[1];

    // output in JSON format without using a JSON library to save dependencies
    StrBuilder buf = new StrBuilder(2048).append('{');

    ByteArrayOutputStream state_1_stream = new ByteArrayOutputStream();
    PrintStream state_1_out = new PrintStream(state_1_stream, true);
    PDEUtilityTools.printSurface("State 1 density", res1, state_1_out);
    state_1_out.close();
    buf.append("\"state_1_data\":\"").append(state_1_stream.toString()).append("\",");

    ByteArrayOutputStream state_2_stream = new ByteArrayOutputStream();
    PrintStream state_2_out = new PrintStream(state_2_stream, true);
    PDEUtilityTools.printSurface("State 2 density", res2, state_2_out);
    state_2_out.close();
    buf.append("\"state_2_data\":\"").append(state_2_stream.toString()).append("\"}");

    buf.replaceAll("\t", "\\t").replaceAll("\r\n", "\\r\\n").replaceAll("\n", "\\n");

    out.print(buf.toString());
}

From source file:com.openkm.servlet.admin.UnitTestingServlet.java

/**
 * Print HTML page header/*from  w w w .  jav  a 2s.  co  m*/
 */
private void header(PrintStream out, String title, String[][] breadcrumb) {
    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
    out.println(
            "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
    out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
    out.println("<head>");
    out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
    out.println("<link rel=\"Shortcut icon\" href=\"favicon.ico\" />");
    out.println("<link rel=\"stylesheet\" href=\"css/style.css\" type=\"text/css\" />");
    out.println("<title>" + title + "</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<ul id=\"breadcrumb\">");

    for (String[] elto : breadcrumb) {
        out.println("<li class=\"path\">");
        out.print("<a href=\"" + elto[0] + "\">" + elto[1] + "</a>");
        out.print("</li>");
    }

    out.println("<li class=\"path\">" + title + "</li>");
    out.println("</ul>");
    out.println("<br/>");
}

From source file:org.apache.jackrabbit.core.state.SessionItemStateManager.java

/**
 * {@inheritDoc}/*from ww  w . ja va  2  s .c om*/
 */
public void dump(PrintStream ps) {
    ps.println("SessionItemStateManager (" + this + ")");
    ps.println();
    ps.print("[transient] ");
    if (transientStore instanceof Dumpable) {
        ((Dumpable) transientStore).dump(ps);
    } else {
        ps.println(transientStore.toString());
    }
    ps.println();
    ps.print("[attic]     ");
    if (atticStore instanceof Dumpable) {
        ((Dumpable) atticStore).dump(ps);
    } else {
        ps.println(atticStore.toString());
    }
    ps.println();
}

From source file:org.apache.hadoop.tracing.TraceAdmin.java

private int addSpanReceiver(List<String> args) throws IOException {
    String className = StringUtils.popOptionWithArgument("-class", args);
    if (className == null) {
        System.err.println("You must specify the classname with -class.");
        return 1;
    }/*w  w w .j a v a2 s . c  om*/
    ByteArrayOutputStream configStream = new ByteArrayOutputStream();
    PrintStream configsOut = new PrintStream(configStream, false, "UTF-8");
    SpanReceiverInfoBuilder factory = new SpanReceiverInfoBuilder(className);
    String prefix = "";
    for (int i = 0; i < args.size(); ++i) {
        String str = args.get(i);
        if (!str.startsWith(CONFIG_PREFIX)) {
            System.err.println("Can't understand argument: " + str);
            return 1;
        }
        str = str.substring(CONFIG_PREFIX.length());
        int equalsIndex = str.indexOf("=");
        if (equalsIndex < 0) {
            System.err.println("Can't parse configuration argument " + str);
            System.err.println("Arguments must be in the form key=value");
            return 1;
        }
        String key = str.substring(0, equalsIndex);
        String value = str.substring(equalsIndex + 1);
        factory.addConfigurationPair(key, value);
        configsOut.print(prefix + key + " = " + value);
        prefix = ", ";
    }

    String configStreamStr = configStream.toString("UTF-8");
    try {
        long id = remote.addSpanReceiver(factory.build());
        System.out.println("Added trace span receiver " + id + " with configuration " + configStreamStr);
    } catch (IOException e) {
        System.out.println("addSpanReceiver error with configuration " + configStreamStr);
        throw e;
    }
    return 0;
}