Example usage for java.io PrintStream println

List of usage examples for java.io PrintStream println

Introduction

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

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminate the line.

Usage

From source file:groovyx.groovyserv.GroovyMain2.java

static void processArgs(String[] args, final PrintStream out, String classpath) { // for GroovyServ
    Options options = buildOptions();//from   ww  w .  j a  v  a  2s.  c  o  m

    try {
        CommandLine cmd = parseCommandLine(options, args);

        if (cmd.hasOption('h')) {
            printHelp(out, options);
        } else if (cmd.hasOption('v')) {
            String version = GroovySystem.getVersion();
            out.println(
                    "Groovy Version: " + version + " JVM: " + System.getProperty("java.version") + " Vendor: "
                            + System.getProperty("java.vm.vendor") + " OS: " + System.getProperty("os.name"));
        } else {
            // If we fail, then exit with an error so scripting frameworks can catch it
            // TODO: pass printstream(s) down through process
            if (!process(cmd, classpath)) {
                System.exit(1);
            }
        }
    } catch (ParseException pe) {
        out.println("error: " + pe.getMessage());
        printHelp(out, options);
    } catch (IOException ioe) {
        out.println("error: " + ioe.getMessage());
    }
}

From source file:groovy.ui.GroovyMain.java

static void processArgs(String[] args, final PrintStream out) {
    Options options = buildOptions();//from   w  w  w  .  j  a va 2s  .  co  m

    try {
        CommandLine cmd = parseCommandLine(options, args);

        if (cmd.hasOption('h')) {
            printHelp(out, options);
        } else if (cmd.hasOption('v')) {
            String version = GroovySystem.getVersion();
            out.println(
                    "Groovy Version: " + version + " JVM: " + System.getProperty("java.version") + " Vendor: "
                            + System.getProperty("java.vm.vendor") + " OS: " + System.getProperty("os.name"));
        } else {
            // If we fail, then exit with an error so scripting frameworks can catch it
            // TODO: pass printstream(s) down through process
            if (!process(cmd)) {
                System.exit(1);
            }
        }
    } catch (ParseException pe) {
        out.println("error: " + pe.getMessage());
        printHelp(out, options);
    } catch (IOException ioe) {
        out.println("error: " + ioe.getMessage());
    }
}

From source file:com.opengamma.analytics.financial.model.finitedifference.applications.PDEUtilityTools.java

/**
 * Prints out the values of the function f(x,y) where x takes the values x_1 to x_N and y takes the values y_1 to y_M, along with the x and y values, with x as the top row and
 * y as the left column. This format can be used by the Excel 3D surface plotter.
 * @param name Optional name for the output
 * @param data The data//from   www .  j a  v  a  2  s .  c o m
 * @param x x-values
 * @param y y-values
 * @param out output
 */
public static void printSurface(final String name, final double[][] data, final double[] x, final double[] y,
        final PrintStream out) {
    ArgumentChecker.notNull(data, "null data");
    ArgumentChecker.notNull(x, "null x");
    ArgumentChecker.notNull(y, "null y");
    ArgumentChecker.notNull(out, "null printStream");
    final int n = data.length;
    final int m = data[0].length;
    ArgumentChecker.isTrue(n == y.length, "Size of data is {} {}, but length of y is {}", n, m, y.length);
    ArgumentChecker.isTrue(m == x.length, "Size of data is {} {}, but length of x is {}", n, m, x.length);

    out.println(name);
    for (int j = 0; j < m; j++) {
        out.print("\t" + x[j]);
    }
    out.print("\n");
    for (int i = 0; i < n; i++) {
        out.print(y[i]);
        for (int j = 0; j < m; j++) {
            out.print("\t" + data[i][j]);
        }
        out.print("\n");
    }
    out.print("\n");
}

From source file:com.bjond.utilities.MiscUtils.java

public static <T> void printSetOfSet(PrintStream ps, Set<Set<T>> sos) {

    for (Set<T> s : sos) {
        ps.print("#" + "{"); // <-- Stupid Eclipse, stupid EL...
        boolean first = true;
        for (T t : s) {
            if (first) {
                first = false;//from  w  ww  .  j a va 2  s .c  o  m
            } else {
                ps.print(",");
            }

            ps.print(t);
        }
        ps.println("}");
    }
}

From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java

/**
 * Enumerate row keys from an SSTableReader and write the result to a
 * PrintStream./*w  ww .java2 s  .c  o m*/
 * 
 * @param desc
 *            the descriptor of the file to export the rows from
 * @param outs
 *            PrintStream to write the output to
 * @throws IOException
 *             on failure to read/write input/output
 */
public static void enumeratekeys(Descriptor desc, PrintStream outs) throws IOException {
    KeyIterator iter = new KeyIterator(desc);
    DecoratedKey lastKey = null;
    while (iter.hasNext()) {
        DecoratedKey key = iter.next();

        // validate order of the keys in the sstable
        if (lastKey != null && lastKey.compareTo(key) > 0)
            throw new IOException("Key out of order! " + lastKey + " > " + key);
        lastKey = key;

        outs.println(ByteBufferUtil.string(key.key));
    }
    iter.close();
    outs.flush();
}

From source file:com.ibm.devops.dra.AbstractDevOpsAction.java

/**
 * check if the root url in the jenkins is set correctly
 * @param printStream//from   ww w.ja va2  s.  c  o  m
 * @return
 */
public static boolean checkRootUrl(PrintStream printStream) {
    if (Util.isNullOrEmpty(Jenkins.getInstance().getRootUrl())) {
        printStream.println(
                "[IBM Cloud DevOps] The Jenkins global root url is not set. Please set it to use this postbuild Action.  \"Manage Jenkins > Configure System > Jenkins URL\"");
        printStream.println("[IBM Cloud DevOps] Error: Failed to upload Build Info.");
        return false;
    }
    return true;
}

From source file:de.citec.sc.index.ProcessAnchorFile.java

public static void run(String filePath) {

    try {//from  w w w.ja v a  2 s .c om
        File file = new File("new.ttl");

        // if file doesnt exists, then create it
        if (file.exists()) {
            file.delete();
            file.createNewFile();
        }
        if (!file.exists()) {
            file.createNewFile();
        }
        BufferedReader wpkg = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"));
        String line = "";

        PrintStream ps = new PrintStream("new.ttl", "UTF-8");

        while ((line = wpkg.readLine()) != null) {

            String[] data = line.split("\t");

            if (data.length == 3) {
                String label = data[0];

                label = StringEscapeUtils.unescapeJava(label);

                try {
                    label = URLDecoder.decode(label, "UTF-8");
                } catch (Exception e) {
                }

                String uri = data[1].replace("http://dbpedia.org/resource/", "");
                uri = StringEscapeUtils.unescapeJava(uri);

                try {
                    uri = URLDecoder.decode(uri, "UTF-8");
                } catch (Exception e) {
                }

                String f = data[2];

                label = label.toLowerCase();
                ps.println(label + "\t" + uri + "\t" + f);

            }

        }

        wpkg.close();
        ps.close();

        File oldFile = new File(filePath);
        oldFile.delete();
        oldFile.createNewFile();

        file.renameTo(oldFile);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:hudson.Util.java

/**
 * Creates a symlink to baseDir+targetPath at baseDir+symlinkPath.
 * <p>/*from w ww .  ja  v  a2 s .c o m*/
 * If there's a prior symlink at baseDir+symlinkPath, it will be overwritten.
 */
public static void createSymlink(File baseDir, String targetPath, String symlinkPath, TaskListener listener)
        throws InterruptedException {
    if (!isWindows() && !NO_SYMLINK) {
        try {
            // ignore a failure.
            new LocalProc(new String[] { "rm", "-rf", symlinkPath }, new String[0], listener.getLogger(),
                    baseDir).join();

            int r = new LocalProc(new String[] { "ln", "-s", targetPath, symlinkPath }, new String[0],
                    listener.getLogger(), baseDir).join();
            if (r != 0)
                listener.getLogger().println("ln failed: " + r);
        } catch (IOException e) {
            PrintStream log = listener.getLogger();
            log.println("ln failed");
            Util.displayIOException(e, listener);
            e.printStackTrace(log);
        }
    }
}

From source file:com.caseystella.analytics.util.DistributionUtil.java

public void summary(String title, DescriptiveStatistics statistics, PrintStream pw) {
    pw.println(title + ": " + "\n\tMin: " + statistics.getMin() + "\n\t1th: " + statistics.getPercentile(1)
            + "\n\t5th: " + statistics.getPercentile(5) + "\n\t10th: " + statistics.getPercentile(10)
            + "\n\t25th: " + statistics.getPercentile(25) + "\n\t50th: " + statistics.getPercentile(50)
            + "\n\t90th: " + statistics.getPercentile(90) + "\n\t95th: " + statistics.getPercentile(95)
            + "\n\t99th: " + statistics.getPercentile(99) + "\n\tMax: " + statistics.getMax() + "\n\tMean: "
            + statistics.getMean() + "\n\tStdDev: " + statistics.getStandardDeviation());
}

From source file:Main.java

public void println(PrintStream out) {
    out.println(this.toString());
}