Example usage for java.io PrintWriter println

List of usage examples for java.io PrintWriter println

Introduction

In this page you can find the example usage for java.io PrintWriter println.

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminates the line.

Usage

From source file:at.tuwien.ifs.somtoolbox.data.InputDataWriter.java

public static void writeTempplateHeaderToFile(PrintWriter writer, String fileName, final int numVectors,
        final int dim, final int numInfo) throws IOException {
    writer.println("$TYPE template");
    writer.println("$XDIM " + numInfo);
    writer.println("$YDIM " + numVectors);
    writer.println("$VEC_DIM " + dim);
}

From source file:edu.uci.ics.asterix.result.ResultUtils.java

public static void webUIErrorHandler(PrintWriter out, Exception e) {
    String errorTemplate = readTemplateFile("/webui/errortemplate.html", "%s\n%s\n%s");

    String errorOutput = String.format(errorTemplate, escapeHTML(extractErrorMessage(e)),
            escapeHTML(extractErrorSummary(e)), escapeHTML(extractFullStackTrace(e)));
    out.println(errorOutput);
}

From source file:com.dumontierlab.pdb2rdf.Pdb2Rdf.java

private static void outputStats(CommandLine cmd, Map<String, Double> stats) throws FileNotFoundException {
    File outputDir = getOutputDirectory(cmd);
    File statsFile = null;//w ww  .  j a  va2  s  .  c  o m
    if (outputDir != null) {
        statsFile = new File(outputDir, STATSFILE_NAME);
    } else {
        statsFile = new File(STATSFILE_NAME);
    }
    PrintWriter out = new PrintWriter(statsFile);
    try {
        for (Map.Entry<String, Double> stat : stats.entrySet()) {
            out.println(stat.getKey() + ": " + stat.getValue());
        }
        out.flush();
    } finally {
        out.close();
    }

}

From source file:examples.echo.java

public static final void echoTCP(String host) throws IOException {
    EchoTCPClient client = new EchoTCPClient();
    BufferedReader input, echoInput;
    PrintWriter echoOutput;
    String line;/*from www  .  j  a  v  a2 s  .  c o m*/

    // We want to timeout if a response takes longer than 60 seconds
    client.setDefaultTimeout(60000);
    client.connect(host);
    System.out.println("Connected to " + host + ".");
    input = new BufferedReader(new InputStreamReader(System.in));
    echoOutput = new PrintWriter(new OutputStreamWriter(client.getOutputStream()), true);
    echoInput = new BufferedReader(new InputStreamReader(client.getInputStream()));

    while ((line = input.readLine()) != null) {
        echoOutput.println(line);
        System.out.println(echoInput.readLine());
    }

    client.disconnect();
}

From source file:com.zimbra.common.util.TemplateCompiler.java

private static void convertLines(PrintWriter out, String pkg, String lines, Map<String, String> attrs,
        boolean authoritative) {
    out.print("AjxTemplate.register(\"");
    out.print(pkg);//from   w  w w  . j ava 2s  . c o  m
    out.println("\", ");
    out.println("function(name, params, data, buffer) {");
    out.println("\tvar _hasBuffer = Boolean(buffer);");
    out.println("\tdata = (typeof data == \"string\" ? { id: data } : data) || {};");
    out.println("\tbuffer = buffer || [];");
    out.println("\tvar _i = buffer.length;");
    out.println();

    Matcher matcher = RE_REPLACE.matcher(lines);
    if (matcher.find()) {
        int offset = 0;
        do {
            int index = matcher.start();
            if (offset < index) {
                printStringLines(out, lines.substring(offset, index));
            }
            String param = matcher.group(1);
            String inline = matcher.group(2);
            if (param != null) {
                printDataLine(out, param);
            } else if (inline != null) {
                printBufferLine(out, inline);
            } else {
                printLine(out, "\t", matcher.group(3).replaceAll("\n", "\n\t"), "\n");
            }
            offset = matcher.end();
        } while (matcher.find());
        if (offset < lines.length()) {
            printStringLines(out, lines.substring(offset));
        }
    } else {
        printStringLines(out, lines);
    }
    out.println();

    out.println("\treturn _hasBuffer ? buffer.length : buffer.join(\"\");");
    out.println("},");
    if (attrs != null && attrs.size() > 0) {
        out.println("{");
        Iterator<String> iter = attrs.keySet().iterator();
        while (iter.hasNext()) {
            String aname = iter.next();
            String avalue = attrs.get(aname);
            out.print("\t\"");
            printEscaped(out, aname);
            out.print("\": \"");
            printEscaped(out, avalue);
            out.print("\"");
            if (iter.hasNext()) {
                out.print(",");
            }
            out.println();
        }
        out.print("}");
    } else {
        out.print("null");
    }
    out.print(", ");
    out.print(authoritative);
    out.println(");");
}

From source file:com.glaf.core.util.IOUtils.java

/**
 * write lines.//w  w  w .  j av a  2  s  .c  o  m
 * 
 * @param os
 *            output stream.
 * @param lines
 *            lines.
 * @throws IOException
 */
public static void writeLines(OutputStream os, String[] lines) throws IOException {
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(os));
    try {
        for (String line : lines)
            writer.println(line);
        writer.flush();
    } finally {
        writer.close();
    }
}

From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftFileWriterUtil.java

private static void writeDescription(PrintWriter out, Hybridization h, Set<Sample> samples) {
    out.print("!Sample_description=");
    final String desc = h.getDescription();
    if (StringUtils.isNotBlank(desc)) {
        out.println(desc);
    } else {//from  w w w.  j  a  v  a2s .c o m
        String comma = "";
        for (final Sample s : samples) {
            out.print(comma);
            out.print(s.getName());
            comma = ", ";
        }
        out.println();
    }
}

From source file:com.bluemarsh.jswat.console.Main.java

/**
 * Interprets the given command via the command parser.
 *
 * @param  output  where to write error messages.
 * @param  parser  the command interpreter.
 * @param  input   the input command./*from   ww  w  .  j  a va  2 s . co  m*/
 */
private static void performCommand(PrintWriter output, CommandParser parser, String input) {
    // Send the input to the command parser, which will run the
    // command and send output to the writer it was assigned earlier.
    try {
        parser.parseInput(input);
    } catch (MissingArgumentsException mae) {
        output.println(mae.getMessage());
        output.println(NbBundle.getMessage(Main.class, "ERR_Main_HelpCommand"));
    } catch (CommandException ce) {
        // Print the message which should explain everything.
        // If there is a root cause, show that, too.
        output.println(ce.getMessage());
        Throwable cause = ce.getCause();
        if (cause != null) {
            String cmsg = cause.getMessage();
            if (cmsg != null) {
                output.println(cmsg);
            }
        }
    }
}

From source file:HLA.java

private static void help(Options options) {
    //String R = "\u001B[30m";
    HelpFormatter formatter = new HelpFormatter();
    formatter.setDescPadding(0);/*from   ww w  .j a v  a 2 s .co  m*/
    String header = "\n" + "Program: Kourami - Graph-guided assembly of HLA typing exons\n" + "Version: "
            + HLA.VERSION + "\n" + "Contact: Heewook Lee <heewookl@cs.cmu.edu>\n\n"
            + "Usage: java -jar <PATH_TO>/Kourami.jar [options] <bam-1> ... <bam-n>\n\n"
            + "   -h,--help                      print this message\n";

    String footer = "\n";
    System.err.println(header);
    PrintWriter tmp = new PrintWriter(System.err);
    formatter.printOptions(tmp, 80, options, 3, 3);
    tmp.println("\n");
    tmp.println("            -hhy+.                o o       o o       o o o o       o o");
    tmp.println(".`           -syss:---.`        o     o o o     o o o         o o o     o o o");
    tmp.println(":+:`     .:/o+++++///ommy+`    o       _  __                               _");
    tmp.println("`yhs/..:osssooooo++++dmNNNdo`   o     | |/ /___  _   _ _ __ __ _ _ __ ___ (_)");
    tmp.println(" /syy///++++ooooooooodNMdNdmh: o      | ' // _ \\| | | | '__/ _` | '_ ` _ \\| |");
    tmp.println(" -do/` .://++++++++oodmmmmmmd-        | . \\ (_) | |_| | | | (_| | | | | | | |");
    tmp.println(" .+:     `.://///+///ommmmdy-         |_|\\_\\___/ \\__,_|_|  \\__,_|_| |_| |_|_|");
    tmp.println("  .          -syo----..``          ");
    tmp.println("            +y+.                \n\n");

    tmp.flush();
    tmp.close();
    System.exit(1);
}

From source file:at.tuwien.ifs.somtoolbox.data.InputDataWriter.java

/** Writes the class information to a tab-separated file. */
public static void writeToFileTabSeparated(SOMLibClassInformation classInfo, String fileName)
        throws IOException, SOMLibFileFormatException {
    PrintWriter writer = FileUtils.openFileForWriting("Tab-separated class info", fileName);
    for (String element : classInfo.getDataNames()) {
        writer.println(element + "\t" + classInfo.getClassName(element));
    }/* w ww . j av  a 2s.c  om*/
    writer.flush();
    writer.close();
}