Example usage for java.io PrintStream printf

List of usage examples for java.io PrintStream printf

Introduction

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

Prototype

public PrintStream printf(String format, Object... args) 

Source Link

Document

A convenience method to write a formatted string to this output stream using the specified format string and arguments.

Usage

From source file:com.t_oster.liblasercut.drivers.LaosCutter.java

private void setSpeed(PrintStream out, float speed) {
    if (currentSpeed != speed) {
        out.printf("7 100 %d\n", (int) (speed * 100));
        currentSpeed = speed;/*from  ww  w . ja  v a 2 s  .  co m*/
    }
}

From source file:org.rhwlab.variationalbayesian.GaussianMixture.java

public void reportEVar(PrintStream str, String varName, double[] var) {
    str.printf("%s", varName);
    for (int i = 0; i < var.length; ++i) {
        str.printf(",%e", var[i]);
    }//from   ww  w.j  a  va  2 s.  co  m
    str.println();
}

From source file:org.rhwlab.variationalbayesian.GaussianMixture.java

public void reportExpVar(PrintStream str, String varName, double[] var) {
    str.printf("%s", varName);
    for (int i = 0; i < var.length; ++i) {
        str.printf(",%f", Math.exp(var[i]));
    }/* ww  w.j a v  a  2  s .  c o  m*/
    str.println();
}

From source file:org.rhwlab.variationalbayesian.GaussianMixture.java

public void reportMatrix(PrintStream str, String name, RealMatrix mat) {
    str.printf("%s\n", name);
    for (int r = 0; r < mat.getRowDimension(); ++r) {
        for (int c = 0; c < mat.getColumnDimension(); ++c) {
            str.printf(" %e", mat.getEntry(r, c));
        }//from   w w  w.jav  a 2s  . com
        str.println();
    }
}

From source file:com.t_oster.liblasercut.drivers.LaosCutter.java

private void setFrequency(PrintStream out, int frequency) {
    if (currentFrequency != frequency) {
        out.printf("7 102 %d\n", frequency);
        currentFrequency = frequency;/*from w  w  w  .j a va2s.  co m*/
    }
}

From source file:org.rhwlab.variationalbayesian.GaussianMixture.java

public void reportVector(PrintStream str, String name, RealVector[] vec) {
    str.printf("%s", name);
    for (int i = 0; i < vec.length; ++i) {
        str.print("(");
        for (int d = 0; d < vec[i].getDimension(); ++d) {
            if (d > 0) {
                str.print(",");
            }//from ww w  .ja  va2s .c om
            str.printf("%f", vec[i].getEntry(d));
        }
        str.print(")");
    }
    str.println();
}

From source file:uk.ac.ebi.mdk.domain.matrix.AbstractReactionMatrix.java

/**
 * Displays the matrix to the desired PrintStream, Seperator, Value for
 * null, Ordering and Molecule/Reaction trim length
 *
 * @param stream//  w ww.  j  a  va 2 s  .  c om
 * @param seperator
 * @param empty The value to replace null values with
 * @param molNameLength Trim molecule names to this length
 * @param rxnNameLength Trim reaction names to this length
 */
public void display(PrintStream stream, char seperator, String empty, int molNameLength, int rxnNameLength) {

    // top-left corner
    stream.printf("%" + molNameLength + "s", "");

    // write reactions
    String format = seperator + " %" + rxnNameLength + "s";
    for (int i = 0; i < reactionCount; i++) {
        stream.printf(format, reactions[i]);
    }
    stream.println();

    String molNameFormat = "%" + molNameLength + "s";
    String valueFormat = seperator + " %" + rxnNameLength + "s";

    for (int i = 0; i < moleculeCount; i++) {

        // write molecule name...
        stream.printf(molNameFormat, molecules[i]);

        // ...and values
        for (int j = 0; j < reactionCount; j++) {
            T value = matrix[i][j];
            stream.printf(valueFormat, (value == null ? empty : value).toString());
        }
        stream.println();

    }

}

From source file:org.rhwlab.variationalbayesian.GaussianMixture.java

public void reportVar(PrintStream str, String varName, double[] var) {
    double sum = 0.0;
    str.printf("%s", varName);
    for (int i = 0; i < var.length; ++i) {
        str.printf(",%f", var[i]);
        sum = sum + var[i];
    }//from   www .jav a 2  s. c  om
    str.printf("\t%f", sum);
    str.println();
}

From source file:org.kuali.kfs.gl.batch.service.impl.CollectorHelperServiceImpl.java

protected boolean loadCollectorBatch(CollectorBatch batch, String fileName, int batchIndex,
        CollectorReportData collectorReportData, List<CollectorScrubberStatus> collectorScrubberStatuses,
        BatchInputFileType collectorInputFileType, PrintStream originEntryOutputPs) {
    boolean isValid = true;

    MessageMap messageMap = batch.getMessageMap();
    // terminate if there were parse errors
    if (messageMap.hasErrors()) {
        isValid = false;/*from ww w.  j  av  a 2s.c o m*/
    }

    if (isValid) {
        collectorReportData.setNumInputDetails(batch);
        // check totals
        isValid = checkTrailerTotals(batch, collectorReportData, messageMap);
    }

    // do validation, base collector files rules and total checks
    if (isValid) {
        isValid = performValidation(batch, messageMap);
    }

    if (isValid) {
        // mark batch as valid
        collectorReportData.markValidationStatus(batch, true);

        prescrubParsedCollectorBatch(batch, collectorReportData);

        String collectorFileDirectoryName = collectorInputFileType.getDirectoryPath();
        // create a input file for scrubber
        String collectorInputFileNameForScrubber = batchFileDirectoryName + File.separator
                + GeneralLedgerConstants.BatchFileSystem.COLLECTOR_BACKUP_FILE
                + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
        PrintStream inputFilePs = null;
        try {
            inputFilePs = new PrintStream(collectorInputFileNameForScrubber);

            for (OriginEntryFull entry : batch.getOriginEntries()) {
                inputFilePs.printf("%s\n", entry.getLine());
            }
        } catch (IOException e) {
            throw new RuntimeException("loadCollectorFile Stopped: " + e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(inputFilePs);
        }

        CollectorScrubberStatus collectorScrubberStatus = collectorScrubberService.scrub(batch,
                collectorReportData, collectorFileDirectoryName);
        collectorScrubberStatuses.add(collectorScrubberStatus);
        processInterDepartmentalBillingAmounts(batch);

        // store origin group, entries, and collector detairs
        String collectorDemergerOutputFileName = batchFileDirectoryName + File.separator
                + GeneralLedgerConstants.BatchFileSystem.COLLECTOR_DEMERGER_VAILD_OUTPUT_FILE
                + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
        batch.setDefaultsAndStore(collectorReportData, collectorDemergerOutputFileName, originEntryOutputPs);
        collectorReportData.incrementNumPersistedBatches();
    } else {
        collectorReportData.incrementNumNonPersistedBatches();
        collectorReportData.incrementNumNotPersistedOriginEntryRecords(batch.getOriginEntries().size());
        collectorReportData.incrementNumNotPersistedCollectorDetailRecords(batch.getCollectorDetails().size());
        // mark batch as invalid
        collectorReportData.markValidationStatus(batch, false);
    }

    return isValid;
}

From source file:org.kuali.kfs.module.ld.batch.service.impl.LaborScrubberProcess.java

protected void createOutputEntry(LaborOriginEntry entry, PrintStream ps) throws IOException {
    try {//from  w ww . j  av  a  2s .c om
        ps.printf("%s\n", entry.getLine());
    } catch (Exception e) {
        throw new IOException(e.toString(), e);
    }
}