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:org.codice.ddf.notifications.commands.ListCommand.java

@Override
protected Object doExecute() throws Exception {

    PrintStream console = System.out;

    String formatString = "%1$-33s %2$-30s %3$-30s %4$-15s %5$-20s %6$-" + MAX_LENGTH + "s%n";

    List<Map<String, Object>> notifications = getNotifications(userId);
    if (notifications == null || notifications.size() == 0) {
        console.println(RED_CONSOLE_COLOR + "No notifications found" + DEFAULT_CONSOLE_COLOR);
    } else {//from www . ja  va  2 s. c  o m
        console.println();
        console.print("Total notifications found: " + notifications.size());
        console.println();
        console.println();
        console.printf(formatString, "", "", "", "", "", "");
        console.print(CYAN_CONSOLE_COLOR);
        console.printf(formatString, ID, USER_ID, TIMESTAMP, APPLICATION, TITLE, MESSAGE);
        console.print(DEFAULT_CONSOLE_COLOR);

        for (Map<String, Object> notification : notifications) {
            Long timestamp = Long.valueOf((String) notification.get(Notification.NOTIFICATION_KEY_TIMESTAMP));
            String dateTime = new DateTime(new Date(timestamp)).toString(DATETIME_FORMATTER);
            String message = (String) notification.get(Notification.NOTIFICATION_KEY_MESSAGE);
            LOGGER.debug("id = {}, userId = {}, timestamp = {}, application = {},  title = {},  message = {}",
                    notification.get(Notification.NOTIFICATION_KEY_ID),
                    notification.get(Notification.NOTIFICATION_KEY_USER_ID), dateTime,
                    notification.get(Notification.NOTIFICATION_KEY_APPLICATION),
                    notification.get(Notification.NOTIFICATION_KEY_TITLE), message);

            console.printf(formatString, notification.get(Notification.NOTIFICATION_KEY_ID),
                    notification.get(Notification.NOTIFICATION_KEY_USER_ID), dateTime,
                    notification.get(Notification.NOTIFICATION_KEY_APPLICATION),
                    notification.get(Notification.NOTIFICATION_KEY_TITLE),
                    message.substring(0, Math.min(message.length(), MAX_LENGTH)));
        }
    }

    return null;
}

From source file:com.zimbra.cs.imap.ImapMessage.java

private static void astring(PrintStream ps, String value, boolean upcase) {
    boolean literal = false;
    StringBuilder nonulls = null;
    int i = 0, lastNull = -1;
    for (int length = value.length(); i < length; i++) {
        char c = value.charAt(i);
        if (c == '\0') {
            if (nonulls == null) {
                nonulls = new StringBuilder();
            }/*ww  w .jav  a 2 s  . co m*/
            nonulls.append(value.substring(lastNull + 1, i));
            lastNull = i;
        } else if (c == '"' || c == '\\' || c >= 0x7f || c < 0x20) {
            literal = true;
        }
    }

    String content = nonulls == null ? value : nonulls.append(value.substring(lastNull + 1, i)).toString();
    if (upcase) {
        content = content.toUpperCase();
    }

    if (!literal) {
        ps.write('"');
        ps.print(content);
        ps.write('"');
    } else {
        try {
            byte[] bytes = content.getBytes(MimeConstants.P_CHARSET_UTF8);
            ps.write('{');
            ps.print(bytes.length);
            ps.write('}');
            ps.write(ImapHandler.LINE_SEPARATOR_BYTES, 0, 2);
            ps.write(bytes, 0, bytes.length);
        } catch (UnsupportedEncodingException uee) {
            ps.write(NIL, 0, 3);
        }
    }
}

From source file:beast.structuredCoalescent.distribution.IndependentStructuredCoalescent.java

@Override
public void init(PrintStream out) {
    for (int i = 0; i < states; i++)
        for (int j = 0; j < states; j++)
            if (i != j)
                out.print("backward_rate_" + i + "to" + j + "\t");
    for (int i = 0; i < states; i++)
        for (int j = 0; j < states; j++)
            if (i != j)
                out.print("forward_rate_" + j + "to" + i + "\t");
    for (int i = 0; i < states; i++)
        out.print("coalescent_rate_deme_" + i + "\t");
    out.print("max_posterior\t");
    for (int i = 0; i < states * (states - 1); i++)
        out.print("max_mig_rate" + i + "\t");
    for (int i = 0; i < states; i++)
        out.print("max_coal_rate" + i + "\t");

}

From source file:net.gbmb.collector.example.SimpleLogPush.java

private String storeArchive(Collection collection) throws IOException {
    String cid = collection.getId();
    java.util.Collection<CollectionRecord> records = collectionRecords.get(cid);

    // index//w  w  w  .ja  v a  2 s  . c om
    ByteArrayOutputStream indexStream = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
    PrintStream output = new PrintStream(indexStream);
    // zip
    ByteArrayOutputStream archiveStream = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
    ZipOutputStream zos = new ZipOutputStream(archiveStream);
    output.println("Serialize collection: " + collection.getId());
    output.println("  creation date: " + collection.getCreationDate());
    output.println("  end date:      " + collection.getEndDate());
    for (CollectionRecord cr : records) {
        output.print(cr.getRecordDate());
        output.print(" ");
        output.println(cr.getContent());
        if (cr.getAttachment() != null) {
            String attName = cr.getAttachment();
            output.println("  > " + attName);
            ZipEntry entry = new ZipEntry(cr.getAttachment());
            zos.putNextEntry(entry);
            InputStream content = temporaryStorage.get(cid, attName);
            IOUtils.copy(content, zos);
        }
    }
    // add the index file
    output.close();
    ZipEntry index = new ZipEntry("index");
    zos.putNextEntry(index);
    IOUtils.write(indexStream.toByteArray(), zos);
    // close zip
    zos.close();
    ByteArrayInputStream content = new ByteArrayInputStream(archiveStream.toByteArray());

    // send to final storage
    return finalStorage.store(cid, content);
}

From source file:com.github.lindenb.jvarkit.util.command.Command.java

protected void printStandardPreamble(PrintStream out) {
    String prg = getName();/*from   w w w  .  j a v  a  2 s  .com*/
    out.println(prg);
    for (int i = 0; i < prg.length(); ++i)
        out.print('=');
    out.println();
    out.print("\nDescription: ");
    out.println(getDescription());
    out.println();
    out.println("Author         : " + getAuthorName());
    out.println("Mail           : " + getAuthorMail());
    out.println("WWW            : " + getOnlineDocUrl());
    out.println("Compilation    : " + getCompileDate());
    out.println("Git-Hash       : " + getVersion());
    out.println("Htsjdk-version : " + HtsjdkVersion.getVersion());
    out.println("Htsjdk-home    : " + HtsjdkVersion.getHome());
}

From source file:iristk.cfg.ABNFGrammar.java

@Override
public void marshal(OutputStream out) {
    PrintStream ps = new PrintStream(out);
    ps.println("#ABNF 1.0 UTF-8;\n");
    if (getLanguage() != null)
        ps.println("language " + getLanguage() + ";");
    if (getRoot() != null)
        ps.println("root $" + getRoot() + ";");
    ps.println();//from   w  ww .  ja  v a 2 s. c om
    for (Object rule : getRules()) {
        if (isPublic(rule))
            ps.print("public ");
        ps.println("$" + getRuleId(rule) + " = " + matchToString(this, getMatches(rule)) + ";");
        ps.println();
    }
}

From source file:at.ac.tuwien.big.moea.print.SolutionWriter.java

@Override
public void write(final PrintStream ps, final S solution) {
    if (solution == null) {
        ps.println("empty-solution");
    }/*from  w  ww .  j  a v  a  2 s  .c o  m*/

    resetIndent();

    if (writeSummaries()) {
        setIndent(0);
        ps.print(printVariableSummary(solution));
        setIndent(2);
    }
    if (writeVariables()) {
        ps.print(printVariables(solution));
    }

    if (writeSummaries()) {
        setIndent(0);
        ps.print(printAttributeSummary(solution));
        setIndent(2);
    }
    if (writeAttributes()) {
        ps.print(printAttributes(solution));
    }

    if (writeSummaries()) {
        setIndent(0);
        ps.print(printObjectiveSummary(solution));
        setIndent(2);
    }
    if (writeObjectives()) {
        ps.print(printObjectives(solution));
    }

    if (writeSummaries()) {
        setIndent(0);
        ps.print(printConstraintSummary(solution));
        setIndent(2);
    }
    if (writeConstraints()) {
        ps.print(printConstraints(solution));
    }
}

From source file:com.google.feedserver.tools.FeedServerClientTool.java

protected void print(PrintStream out, String s) {
    printIndentation(out);
    out.print(s);
}

From source file:com.zilbo.flamingSailor.TE.model.TextLine.java

@Override
public void dumpChildren(PrintStream out, int level) {

    StringBuilder sb = new StringBuilder();

    sb.append(StringUtils.repeat("..", level));
    sb.append(getClass().getSimpleName());
    if (isHeading()) {
        sb.append("      (H) ");
    }//from w  w  w . j  a v  a  2s. c om
    if (sb.length() < 20) {
        sb.append(StringUtils.repeat(' ', 20 - sb.length()));
    }
    sb.append('\t');

    sb.append(getRectangleDebug()).append("\t");

    out.print(sb.toString() + " " + normHistoGramToString() + String.format(" H:%5.1f W:%6.1f D:%4.2f P:%4.2f",
            height(), width(), density(), getLineIsRegularProbability()) + "\t");

    String text;
    text = getText().replace("\n", "\n" + StringUtils.repeat(' ', 43));

    if (text.length() > 256) {
        text = text.substring(0, 256 - 4) + " ...";

    }

    out.println(text);
    /*
      for (Component component : getChildren()) {
    component.dumpChildren(out, level + 1);
      }
      */
}

From source file:beast.structuredCoalescent.distribution.IndependentStructuredCoalescent.java

@Override
public void log(int nSample, PrintStream out) {
    int c = 0;/* ww w .  ja v  a2 s  . c o m*/
    for (int i = 0; i < states; i++)
        for (int j = 0; j < states; j++)
            if (i != j) {
                out.print(migrationRatesInput.get().getArrayValue(c) + "\t");
                c++;
            }

    c = 0;
    for (int i = 0; i < states; i++)
        for (int j = 0; j < states; j++)
            if (i != j) {
                out.print(
                        migrationRatesInput.get().getArrayValue(c) / coalescentRatesInput.get().getArrayValue(j)
                                * coalescentRatesInput.get().getArrayValue(i) + "\t");
                c++;
            }
    for (int i = 0; i < states; i++)
        out.print(coalescentRatesInput.get().getArrayValue(i) + "\t");

    out.print(max_posterior + "\t");
    for (int i = 0; i < states * (states - 1); i++)
        out.print(max_mig[i] + "\t");
    for (int i = 0; i < states; i++)
        out.print(max_coal[i] + "\t");

}