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.apache.rat.Report.java

private IReportable getDirectory(PrintStream out) {
    File base = new File(baseDirectory);
    if (!base.exists()) {
        out.print("ERROR: ");
        out.print(baseDirectory);//  w w w .  j  a  v a2 s. co  m
        out.print(" does not exist.\n");
        return null;
    }

    if (base.isDirectory()) {
        return new DirectoryWalker(base, inputFileFilter);
    }

    try {
        return new ArchiveWalker(base, inputFileFilter);
    } catch (IOException ex) {
        out.print("ERROR: ");
        out.print(baseDirectory);
        out.print(" is not valid gzip data.\n");
        return null;
    }
}

From source file:herbie.running.population.algorithms.AbstractClassifiedFrequencyAnalysis.java

/**
 * Prints the crosstab.//from   w  w  w .j  ava 2 s . co m
 *
 * @param crosstabFormat indicates if absolute numbers or percentage of all legs are printed
 * @param isCumulative indicates if cumulative numbers are printed
 * @param classes the classification of distances
 */
public void printClasses(CrosstabFormat crosstabFormat, boolean isCumulative, double[] classes,
        PrintStream out) {
    long numberOfLegs;
    out.println();
    /*
     * header - start
     */
    out.print("#i\tclass");
    for (String mode : this.frequencies.keySet()) {
        out.print("\t" + mode);
    }
    out.print("\tsum");
    out.println();
    /*
     * header - end
     */

    /*
     * table - start
     */
    for (int i = 0; i < classes.length; i++) {
        long sumClass = 0;
        out.print(Integer.toString(i) + "\t");
        out.print(classFormat.format(classes[i]));
        for (String mode : this.frequencies.keySet()) {
            out.print("\t");
            if (isCumulative) {
                numberOfLegs = this.getNumberOfLegs(mode, DUMMY_NEGATIVE_BOUND, classes[i]);
            } else {
                numberOfLegs = this.getNumberOfLegs(mode, ((i == 0) ? DUMMY_NEGATIVE_BOUND : classes[i - 1]),
                        classes[i]);
            }
            sumClass += numberOfLegs;

            switch (crosstabFormat) {
            case ABSOLUTE:
                out.print(Long.toString(numberOfLegs));
                break;
            case PERCENTAGE:
                out.print(percentFormat.format((double) numberOfLegs / (double) this.getNumberOfLegs()));
                break;
            }
        }
        out.print("\t");

        switch (crosstabFormat) {
        case ABSOLUTE:
            out.print(Long.toString(sumClass));
            break;
        case PERCENTAGE:
            out.print(percentFormat.format((double) sumClass / (double) this.getNumberOfLegs()));
            break;
        }
        out.println();
    }
    /*
     * table - end
     */

    /*
     * sum - start
     */
    out.print("#sum\t");
    for (String mode : this.frequencies.keySet()) {
        out.print("\t");
        numberOfLegs = this.getNumberOfLegs(mode);

        switch (crosstabFormat) {
        case ABSOLUTE:
            out.print(numberOfLegs);
            break;
        case PERCENTAGE:
            out.print(percentFormat.format((double) numberOfLegs / (double) this.getNumberOfLegs()));
            break;
        }
    }
    out.print("\t");
    numberOfLegs = this.getNumberOfLegs();

    switch (crosstabFormat) {
    case ABSOLUTE:
        out.print(Long.toString(numberOfLegs));
        break;
    case PERCENTAGE:
        out.print(percentFormat.format(1.0));
        break;
    }
    /*
     * sum - end
     */
    out.println();
}

From source file:org.apache.bookkeeper.common.conf.ConfigDef.java

private void writeSentence(PrintStream stream, String prefix, String sentence) {
    int max = MAX_COLUMN_SIZE;
    String[] words = sentence.split(" ");
    int i = 0;//from  w  w  w.j a va  2  s.c om
    stream.print(prefix);
    int current = prefix.length();
    while (i < words.length) {
        String word = words[i];
        if (word.length() > max || current + word.length() <= max) {
            if (i != 0) {
                stream.print(" ");
            }
            stream.print(word);
            current += (word.length() + 1);
        } else {
            stream.println();
            stream.print(prefix);
            stream.print(word);
            current = prefix.length() + word.length();
        }
        ++i;
    }
    stream.println();
}

From source file:org.matsim.contrib.freight.usecases.analysis.LegHistogram.java

/**
 * Writes the gathered data tab-separated into a text stream.
 *
 * @param stream The data stream where to write the gathered data.
 *//*from   ww w .  j  a  v  a 2  s. c o  m*/
public void write(final PrintStream stream) {
    stream.print("time\ttime\tdepartures_all\tarrivals_all\tstuck_all\ten-route_all");
    for (String legMode : this.data.keySet()) {
        stream.print("\tdepartures_" + legMode + "\tarrivals_" + legMode + "\tstuck_" + legMode + "\ten-route_"
                + legMode);
    }
    stream.print("\n");
    int allEnRoute = 0;
    int[] modeEnRoute = new int[this.data.size()];
    for (int i = 0; i < this.allModesData.countsDep.length; i++) {
        // data about all modes
        allEnRoute = allEnRoute + this.allModesData.countsDep[i] - this.allModesData.countsArr[i]
                - this.allModesData.countsStuck[i];
        stream.print(Time.writeTime(i * this.binSize) + "\t" + i * this.binSize);
        stream.print("\t" + this.allModesData.countsDep[i] + "\t" + this.allModesData.countsArr[i] + "\t"
                + this.allModesData.countsStuck[i] + "\t" + allEnRoute);

        // data about single modes
        int mode = 0;
        for (ModeData modeData : this.data.values()) {
            modeEnRoute[mode] = modeEnRoute[mode] + modeData.countsDep[i] - modeData.countsArr[i]
                    - modeData.countsStuck[i];
            stream.print("\t" + modeData.countsDep[i] + "\t" + modeData.countsArr[i] + "\t"
                    + modeData.countsStuck[i] + "\t" + modeEnRoute[mode]);
            mode++;
        }

        // new line
        stream.print("\n");
    }
}

From source file:edu.harvard.hul.ois.fits.tools.ToolBelt.java

public void printToolInfo(boolean sysInfo, PrintStream p) {
    if (sysInfo) {
        //system info
        p.println("OS Name = " + System.getProperty("os.name"));
        p.println("OS Arch = " + System.getProperty("os.arch"));
        p.println("OS Version = " + System.getProperty("os.version"));
        p.println("------------------------------------");
    }/*  w  w w.  j a  v  a2 s .  c  o  m*/

    for (Tool t : tools) {
        p.print(t.getToolInfo().print());
    }

}

From source file:org.fusesource.hawtjni.generator.HawtJNI.java

private void generateFromResource(String resource, File target) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    InputStream is = getClass().getClassLoader().getResourceAsStream(resource);
    FileSupport.copy(is, out);//from   w ww  . ja v  a  2 s  . c om
    String content = new String(out.toByteArray(), "UTF-8");
    String[] parts = content.split(Pattern.quote("/* == HEADER-SNIP-LOCATION == */"));
    if (parts.length == 2) {
        content = parts[1];
    }
    out.reset();
    PrintStream ps = new PrintStream(out);
    ps.print(JNIGenerator.fixDelimiter(getCopyright()));
    ps.print(JNIGenerator.fixDelimiter(content));
    ps.close();
    if (FileSupport.write(out.toByteArray(), target)) {
        progress("Wrote: " + target);
    }
}

From source file:org.openmrs.module.pacsintegration.component.HL7ListenerComponentTest.java

@Test
public void shouldCreateTwoReportsIfBodyDifferent() throws Exception {

    ModuleActivator activator = new PacsIntegrationActivator();
    activator.started();//from   w  w  w . ja va2 s  .c  o  m
    Context.getService(PacsIntegrationService.class).initializeHL7Listener();

    List<Patient> patients = patientService.getPatients(null, "101-6",
            Collections.singletonList(emrApiProperties.getPrimaryIdentifierType()), true);
    assertThat(patients.size(), is(1)); // sanity check
    Patient patient = patients.get(0);
    List<Encounter> encounters = encounterService.getEncounters(patient, null, null, null, null,
            Collections.singletonList(radiologyProperties.getRadiologyReportEncounterType()), null, null, null,
            false);
    assertThat(encounters.size(), is(0)); // sanity check

    try {
        String message1 = "MSH|^~\\&|HMI|Mirebalais Hospital|RAD|REPORTS|20130228174549||ORU^R01|RTS01CE16055AAF5290|P|2.3|\r"
                + "PID|1||101-6||Patient^Test^||19770222|M||||||||||\r" + "PV1|1||||||||||||||||||\r"
                + "OBR|1||0000001297|127689^SOME_X-RAY|||20130228170556||||||||||||MBL^CR||||||F|||||||Test&Goodrich&Mark&&&&||||20130228170556\r"
                + "OBX|1|TX|127689^SOME_X-RAY||Clinical Indication: ||||||F\r";

        String message2 = "MSH|^~\\&|HMI|Mirebalais Hospital|RAD|REPORTS|20130228174549||ORU^R01|RTS01CE16055AAF5290|P|2.3|\r"
                + "PID|1||101-6||Patient^Test^||19770222|M||||||||||\r" + "PV1|1||||||||||||||||||\r"
                + "OBR|1||0000001297|127689^SOME_X-RAY|||20130228170556||||||||||||MBL^CR||||||F|||||||Test&Goodrich&Mark&&&&||||20130228170556\r"
                + "OBX|1|TX|127689^SOME_X-RAY||Another Clinical Indication: ||||||F\r";

        Thread.sleep(2000); // give the simple server time to start

        Socket socket = new Socket("127.0.0.1", 6665);

        PrintStream writer = new PrintStream(socket.getOutputStream());

        writer.print(header);
        writer.print(message1);
        writer.print(trailer + "\r");
        writer.flush();

        writer.print(header);
        writer.print(message2);
        writer.print(trailer + "\r");
        writer.flush();

        Thread.sleep(2000);

        encounters = encounterService.getEncounters(patient, null, null, null, null,
                Collections.singletonList(radiologyProperties.getRadiologyReportEncounterType()), null, null,
                null, false);
        assertThat(encounters.size(), is(2));

    } finally {
        activator.stopped();
    }

}

From source file:beast.evolution.tree.partitioned.IndividualSEIR.java

public void init(final PrintStream out) {
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print(outbreak.getEverInfectedCases().get(i) + "_infectionTime\t");
    }//  w ww  . j a  v  a  2  s  . c om
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print(outbreak.getEverInfectedCases().get(i) + "_infectiousTime\t");
    }
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print(outbreak.getEverInfectedCases().get(i) + "_infectiousPeriod\t");
    }
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print(outbreak.getEverInfectedCases().get(i) + "_lengthOfInfection\t");
    }
    out.print("bhm_logP" + "\t");
}

From source file:com.zhonghui.tool.controller.HttpClient.java

/**
 * HTTP Post???/*  w  w w . ja  v a 2 s. c  om*/
 *
 * @param connection 
 * @param message ???
 * @throws IOException
 */
private void requestServer(final URLConnection connection, String message, String encoder) throws Exception {
    PrintStream out = null;
    try {
        connection.connect();
        out = new PrintStream(connection.getOutputStream(), false, encoder);
        out.print(message);
        out.flush();
    } catch (Exception e) {
        throw e;
    } finally {
        if (null != out) {
            out.close();
        }
    }
}

From source file:beast.evolution.tree.partitioned.IndividualSEIR.java

public void log(final int sample, final PrintStream out) {
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print(tree.getInfectionTime(outbreak.getEverInfectedCase(i)) + "\t");
    }//from   www .  j ava 2 s  .  com
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print(getInfectiousTime(outbreak.getEverInfectedCase(i)) + "\t");
    }
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print((outbreak.getEverInfectedCase(i).getEndTime()
                - getInfectiousTime(outbreak.getEverInfectedCase(i))) + "\t");
    }
    for (int i = 0; i < outbreak.getEverInfectedCases().size(); i++) {
        out.print((outbreak.getEverInfectedCase(i).getEndTime()
                - tree.getInfectionTime(outbreak.getEverInfectedCase(i))) + "\t");
    }
    out.print(logP + "\t");
}