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:net.imagini.cassandra.DumpSSTables.SSTableExport.java

/**
 * Serialize columns using given column iterator
 * //from w w w. ja  v a2  s .  co m
 * @param columns
 *            column iterator
 * @param out
 *            output stream
 * @param comparator
 *            columns comparator
 * @param cfMetaData
 *            Column Family metadata (to get validator)
 */
private static void serializeColumns(Iterator<OnDiskAtom> columns, PrintStream out, AbstractType<?> comparator,
        CFMetaData cfMetaData) {
    while (columns.hasNext()) {
        writeJSON(out, serializeColumn(columns.next(), comparator, cfMetaData));

        if (columns.hasNext())
            out.print(", ");
    }
}

From source file:com.aptana.core.epl.downloader.RepositoryStatusHelper.java

private static void deeplyPrint(Throwable t, PrintStream strm, boolean stackTrace, int level) {
    if (t instanceof CoreException)
        deeplyPrint((CoreException) t, strm, stackTrace, level);
    else {/*w w w .j ava  2s.  c  o  m*/
        appendLevelString(strm, level);
        if (stackTrace)
            t.printStackTrace(strm);
        else {
            strm.println(t.toString());
            Throwable cause = t.getCause();
            if (cause != null) {
                strm.print("Caused by: "); //$NON-NLS-1$
                deeplyPrint(cause, strm, stackTrace, level);
            }
        }
    }
}

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

private static void astring(PrintStream ps, String value) {
    if (value == null) {
        ps.print("\"\"");
    } else {// w w  w  .  j  av a 2 s.c om
        astring(ps, value, false);
    }
}

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

private static void aSTRING(PrintStream ps, String value) {
    if (value == null) {
        ps.print("\"\"");
    } else {/*from w w w. j  a v  a2s. c  om*/
        astring(ps, value, true);
    }
}

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

private static void ndisposition(PrintStream ps, String disposition) {
    if (disposition == null) {
        ps.print("NIL");
    } else {//from   w  w w  . j  a  va2 s . co m
        ContentDisposition cdisp = new ContentDisposition(disposition);
        ps.write('(');
        astring(ps, cdisp.getDisposition());
        ps.write(' ');
        nparams(ps, cdisp);
        ps.write(')');
    }
}

From source file:com.sonarsource.lits.Dump.java

static void save(List<IssueKey> issues, File dir) {
    try {// ww w . j ava 2  s  . c  o  m
        FileUtils.forceMkdir(dir);
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }

    Collections.sort(issues, new IssueKeyComparator());

    PrintStream out = null;
    String prevRuleKey = null;
    String prevComponentKey = null;
    for (IssueKey issueKey : issues) {
        if (!issueKey.ruleKey.equals(prevRuleKey)) {
            if (out != null) {
                endRule(out);
            }
            try {
                out = new PrintStream(new FileOutputStream(new File(dir, ruleKeyToFileName(issueKey.ruleKey))),
                        /* autoFlush: */ true, StandardCharsets.UTF_8.name());
            } catch (IOException e) {
                throw Throwables.propagate(e);
            }
            out.print("{\n");
            startComponent(out, issueKey.componentKey);
        } else if (!issueKey.componentKey.equals(prevComponentKey)) {
            endComponent(out);
            startComponent(out, issueKey.componentKey);
        }
        out.print(issueKey.line + ",\n");
        prevComponentKey = issueKey.componentKey;
        prevRuleKey = issueKey.ruleKey;
    }
    if (out != null) {
        endRule(out);
    }
}

From source file:org.apache.ofbiz.base.util.KeyStoreUtil.java

public static Certificate pemToCert(Reader r) throws IOException, CertificateException {
    String header = "-----BEGIN CERTIFICATE-----";
    String footer = "-----END CERTIFICATE-----";

    BufferedReader reader = new BufferedReader(r);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);

    String line;/*from   ww  w .  ja  va2 s. co  m*/

    // ignore up to the header
    while ((line = reader.readLine()) != null && !line.equals(header)) {
    }

    // no header found
    if (line == null) {
        throw new IOException("Error reading certificate, missing BEGIN boundary");
    }

    // in between the header and footer is the actual certificate
    while ((line = reader.readLine()) != null && !line.equals(footer)) {
        line = line.replaceAll("\\s", "");
        ps.print(line);
    }

    // no footer found
    if (line == null) {
        throw new IOException("Error reading certificate, missing END boundary");
    }
    ps.close();

    // decode the buffer to a X509Certificate

    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    byte[] certBytes = Base64.decodeBase64(baos.toByteArray());
    return cf.generateCertificate(new ByteArrayInputStream(certBytes));
}

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

private static void nlist(PrintStream ps, String[] list) {
    if (list == null || list.length == 0) {
        ps.print("NIL");
    } else if (list.length == 1) {
        astring(ps, list[0]);/*from  w ww .  ja  va 2  s.  co m*/
    } else {
        ps.write('(');
        for (int i = 0; i < list.length; i++) {
            if (i != 0) {
                ps.write(' ');
            }
            astring(ps, list[i]);
        }
        ps.write(')');
    }
}

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

/**
 * This function computes the split points for a range 
 * [start, end].//from   www. j  a va2s  .  c  om
 * @param start starting point for the range to split.
 * @param end   ending point for the range to split.
 * @param numsplits number of splits to create for the range.
 * @return a list of split points in text format.
 */
public static void writeRanges(long start, long end, int partitionCount, PrintStream out) {
    long rangeSize = (end - start + 1) / partitionCount;
    long rangeStart = start;
    long rangeEnd = start - 1 + rangeSize;

    while (rangeStart <= end) {
        if (rangeEnd > end) {
            rangeEnd = end;
        }
        out.print(rangeStart);
        out.print(' ');
        out.println(rangeEnd);
        rangeStart += rangeSize;
        rangeEnd = rangeStart + rangeSize - 1;
    }
}

From source file:org.bankinterface.util.KeyStoreUtil.java

public static Certificate pemToCert(Reader r) throws IOException, CertificateException {
    String header = "-----BEGIN CERTIFICATE-----";
    String footer = "-----END CERTIFICATE-----";

    BufferedReader reader = new BufferedReader(r);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);

    String line;/*  w  w  w  .ja v a  2 s. c om*/

    // ignore up to the header
    while ((line = reader.readLine()) != null && !line.equals(header)) {
    }

    // no header found
    if (line == null) {
        throw new IOException("Error reading certificate, missing BEGIN boundary");
    }

    // in between the header and footer is the actual certificate
    while ((line = reader.readLine()) != null && !line.equals(footer)) {
        line = line.replaceAll("\\s", "");
        ps.print(line);
    }

    // no footer found
    if (line == null) {
        throw new IOException("Error reading certificate, missing END boundary");
    }
    ps.close();

    // decode the buffer to a X509Certificate
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    byte[] certBytes = Base64.decodeBase64(baos.toByteArray());
    return cf.generateCertificate(new ByteArrayInputStream(certBytes));
}