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:com.zimbra.cs.redolog.util.RedoLogVerify.java

private static void printOp(PrintStream out, RedoableOp op, boolean hideOffset, long beginOffset, long size) {
    if (!hideOffset)
        out.printf("[%08x - %08x: %d bytes; tstamp: %s] ", beginOffset, beginOffset + size - 1, size,
                sDateFormatter.format(new Date(op.getTimestamp())));
    out.println(op.toString());
}

From source file:com.lagrange.LabelApp.java

/**
 * Prints the labels received from the Vision API.
 *//*from w  ww  .j a  v a  2s .  com*/
public static void printLabels(PrintStream out, Path imagePath, List<EntityAnnotation> labels) {
    out.printf("Labels for image %s:\n", imagePath);
    for (EntityAnnotation label : labels) {
        out.printf("\t%s (score: %.3f)\n", label.getDescription(), label.getScore());
    }
    try {
        sendPhotoToTelegramBot();
        sendMessageToTelegramBot(labels);
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (labels.isEmpty()) {
        out.println("\tNo labels found.");
    }

}

From source file:com.xylocore.copybook.runtime.internal.AbstractCopybookGenerator.java

private static void generateDelegationSectionTitle(PrintStream aOutputStream, String aTitle) {
    aOutputStream.println("    //");
    aOutputStream.println("    // " + aTitle + " delegation");
    aOutputStream.println("    //");
    aOutputStream.println();/* w  w  w. java 2 s.  co  m*/
    aOutputStream.println();
}

From source file:com.yahoo.ycsb.bulk.hbase.BulkDataGeneratorJob.java

public static void printKeyValues(Configuration conf, String[] keys, PrintStream out) {
    for (String k : keys) {
        out.print(k);//from   ww w . j av a 2  s. co m
        out.print('=');
        out.println(conf.get(k));
    }

    out.println();
}

From source file:Transform.java

public static void multiplePages() throws Exception {
    InputStream isXML = Transform.class.getResourceAsStream(file("manual.xml"));
    InputStream isXSL = Transform.class.getResourceAsStream("html-pages.xsl");

    StreamSource xsl = new StreamSource(isXSL);
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer(xsl);

    Match manual = $(isXML);/*  www .ja  v  a  2  s . co  m*/
    replaceVariables(manual);

    List<String> ids = manual.find("section").ids();
    HashSet<String> uniqueIds = new HashSet<String>(ids);

    if (ids.size() != uniqueIds.size()) {
        for (String id : uniqueIds) {
            ids.remove(id);
        }

        throw new Exception("Duplicate section ids found! " + ids);
    }

    int blanks = 0, completed = 0;
    for (Match section : manual.find("section").each()) {
        Match sections = section.add(section.parents("section")).reverse();

        String path = path(StringUtils.join(sections.ids(), "/"));
        String relativePath = relative(path);
        String root = root();
        File dir = new File(path);
        dir.mkdirs();

        PrintStream stream = System.out;
        boolean blank = StringUtils.isBlank(section.find("content").text());
        if (blank) {
            blanks++;
            stream = System.err;
        } else {
            completed++;
        }

        stream.print("[");
        stream.print(blank ? " " : "x");
        stream.println("] Transforming section " + path);

        File file = new File(dir, "index.php");
        file.delete();
        FileOutputStream out = new FileOutputStream(file);

        Source source = new DOMSource(manual.document());
        Result target = new StreamResult(out);

        transformer.setParameter("sectionID", section.id());
        transformer.setParameter("relativePath", relativePath);
        transformer.setParameter("root", root);
        transformer.transform(source, target);

        out.close();
    }
    System.out.println("    Completed sections : " + completed + " / " + (blanks + completed) + " ("
            + (100 * completed / (blanks + completed)) + "%)");
}

From source file:dk.hippogrif.prettyxml.app.Main.java

private static void optionUsage(PrintStream ps) {
    for (Iterator iter = optionList.iterator(); iter.hasNext();) {
        Option option = (Option) iter.next();
        ps.print("  -" + option.getOpt());
        String spaces = "              ";
        int i = 0;
        if (option.hasArg()) {
            ps.print(" " + option.getArgName());
            i = option.getArgName().length() + 1;
        }/*from  w w w. j av  a  2  s.  co  m*/
        ps.print(spaces.substring(i));
        ps.println(option.getDescription());
    }
}

From source file:com.xylocore.copybook.runtime.internal.AbstractCopybookGenerator.java

private static void generateHeader(PrintStream aOutputStream) {

    aOutputStream.println("//");
    aOutputStream.println("//   Copyright 2013 The Palantir Corporation");
    aOutputStream.println("//");
    aOutputStream.println("//   Licensed under the Apache License, Version 2.0 (the \"License\");");
    aOutputStream.println("//   you may not use this file except in compliance with the License.");
    aOutputStream.println("//   You may obtain a copy of the License at");
    aOutputStream.println("//");
    aOutputStream.println("//       http://www.apache.org/licenses/LICENSE-2.0");
    aOutputStream.println("//");
    aOutputStream.println("//   Unless required by applicable law or agreed to in writing, software");
    aOutputStream.println("//   distributed under the License is distributed on an \"AS IS\" BASIS,");
    aOutputStream.println("//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    aOutputStream.println("//   See the License for the specific language governing permissions and");
    aOutputStream.println("//   limitations under the License.");
    aOutputStream.println("//");
    aOutputStream.println();//w ww.j  a  v  a  2 s.  c om
    aOutputStream.println();
    aOutputStream.println("package com.xylocore.commons.data.copybook.runtime;");
    aOutputStream.println();
    aOutputStream.println("import java.math.BigDecimal;");
    aOutputStream.println("import java.math.BigInteger;");
    aOutputStream.println("import java.util.Date;");
    aOutputStream.println();
    aOutputStream.println("import com.xylocore.commons.data.copybook.runtime.CopybookContext;");
    aOutputStream.println("import com.xylocore.commons.data.copybook.runtime.converters.Converter;");
    aOutputStream.println("import com.xylocore.commons.data.copybook.runtime.nulleq.NullEquivalentStrategy;");
    aOutputStream.println();
    aOutputStream.println();
    aOutputStream.println("/**");
    aOutputStream.println(" * FILLIN");
    aOutputStream.println(" * ");
    aOutputStream.println(" * @author      Eric R. Medley");
    aOutputStream.println(" */");
    aOutputStream.println();
    aOutputStream.println("public abstract class AbstractCopybook");
    aOutputStream.println("    extends");
    aOutputStream.println("        AbstractCopybookBase");
    aOutputStream.println("{");
}

From source file:com.wandrell.example.swss.client.console.ConsoleClient.java

/**
 * Calls the endpoint in the specified URI by using the received client.
 * <p>/*  w ww. j a  v a 2s  .  c o m*/
 * This client is expected to be prepared for calling the endpoint, which
 * mostly means being set up for the same security protocol it uses.
 * <p>
 * If an exception occurs while using the client an error warning will be
 * printed in the console.
 *
 * @param client
 *            client which will call the endpoint
 * @param uri
 *            URI for the endpoint
 * @param output
 *            output for the client to print information
 * @param scanner
 *            scanner for the input
 */
private static final void callEndpoint(final EntityClient client, final String uri, final PrintStream output,
        final Scanner scanner) {
    final ExampleEntity entity; // Queried entity
    final Integer id; // Id for the query

    output.println("------------------------------------");
    output.println("Write the id of the entity to query.");
    output.println("The id 1 is always valid.");
    output.println("------------------------------------");

    output.println();
    output.print("Id: ");
    id = getInteger(scanner);
    output.println();

    try {
        entity = client.getEntity(uri, id);

        if ((entity == null) || (entity.getId() < 0)) {
            // No entity found
            output.println(String.format("No entity with id %d exists", id));
        } else {
            // Entity found
            output.println("Found entity.");
            output.println();
            output.println(String.format("Entity id:\t%d", entity.getId()));
            output.println(String.format("Entity name:\t%s", entity.getName()));
        }
    } catch (final NestedRuntimeException e) {
        output.println(String.format("Error: %s", e.getMostSpecificCause().getMessage()));
    } catch (final Exception e) {
        output.println(String.format("Error: %s", e.getMessage()));
    }

    // Waits so the result information can be checked
    waitForEnter(output, scanner);
}

From source file:hudson.plugins.trackplus.Updater.java

/**
 * Submits comments for the given issues.
 * Removes from <code>issues</code> the ones which appear to be invalid.
 * @param build/*from   ww w .  j  a  v a 2 s  . c om*/
 * @param logger
 * @param hudsonRootUrl
 * @param issues
 * @param session
 * @param recordScmChanges
 * @throws RemoteException
 */
static void submitComments(AbstractBuild<?, ?> build, PrintStream logger, String hudsonRootUrl,
        List<TrackplusIssue> issues, TrackplusSession session, boolean recordScmChanges)
        throws RemoteException {
    // copy to prevent ConcurrentModificationException
    List<TrackplusIssue> copy = new ArrayList<TrackplusIssue>(issues);
    for (TrackplusIssue issue : copy) {
        try {
            logger.println(Messages.Updater_Updating(issue.getId()));
            StringBuilder aggregateComment = new StringBuilder();
            for (Entry e : build.getChangeSet()) {
                if (e.getMsg().contains(Integer.toString(issue.getId()))) {
                    aggregateComment.append(e.getMsg()).append("<br>");
                }
            }
            session.addComment(issue.getId(),
                    createComment(build, hudsonRootUrl, aggregateComment.toString(), recordScmChanges, issue));
        } catch (TCLFacadeException e) {
            String message = TrackplusSession.getMessage(e);
            logger.println("Can't add comment at " + issue.getId() + ".\n" + message);
            issues.remove(issue);
        }
    }
}

From source file:com.bigdata.dastor.tools.SSTableExport.java

/**
 * Enumerate row keys from an SSTableReader and write the result to a PrintStream.
 * /*from w w w .ja  v  a2 s . c om*/
 * @param ssTableFile 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(String ssTableFile, PrintStream outs) throws IOException {
    IPartitioner partitioner = StorageService.getPartitioner();
    BufferedRandomAccessFile input = new BufferedRandomAccessFile(SSTable.indexFilename(ssTableFile), "r");
    while (!input.isEOF()) {
        DecoratedKey decoratedKey = partitioner.convertFromDiskFormat(input.readUTF());
        long dataPosition = input.readLong();
        outs.println(decoratedKey.key);
    }

    outs.flush();
}