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:edu.oregonstate.eecs.mcplan.search.UctNegamaxSearch.java

private void printStateNode(final StateNode sn, final int depth, final PrintStream out) {
    for (int i = 0; i < depth; ++i) {
        out.print("  ");
    }//from ww  w. j  a v a2s  .c  o  m
    out.print("S");
    out.print(depth / 2);
    out.print(": n = ");
    out.print(sn.n);
    out.print(": ");
    out.println(sn.token);
    for (final Map.Entry<A, ActionNode> e : sn.a_.entrySet()) {
        printActionNode(e.getValue(), depth + 1, out);
    }
}

From source file:org.fao.geonet.utils.Xml.java

/**
 * Loads an xml file from a URL after posting content to the URL.
 *
 * @param url/*from  w  w w  .j  ava2 s .c  o m*/
 * @param xmlQuery
 * @return
 * @throws IOException
 * @throws JDOMException
 */
public static Element loadFile(URL url, Element xmlQuery) throws IOException, JDOMException {
    Element result = null;
    try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/xml");
        connection.setRequestProperty("Content-Length",
                "" + Integer.toString(getString(xmlQuery).getBytes(ENCODING).length));
        connection.setRequestProperty("Content-Language", "en-US");
        connection.setDoOutput(true);
        PrintStream out = new PrintStream(connection.getOutputStream(), true, ENCODING);
        out.print(getString(xmlQuery));
        out.close();

        SAXBuilder builder = getSAXBuilderWithoutXMLResolver(false);//new SAXBuilder();
        Document jdoc = builder.build(connection.getInputStream());

        result = (Element) jdoc.getRootElement().detach();
    } catch (Exception e) {
        Log.error(Log.ENGINE, "Error loading URL " + url.getPath() + " .Threw exception " + e);
        e.printStackTrace();
    }
    return result;
}

From source file:edu.oregonstate.eecs.mcplan.search.UctNegamaxSearch.java

private void printActionNode(final ActionNode an, final int depth, final PrintStream out) {
    for (int i = 0; i < depth; ++i) {
        out.print("  ");
    }/*from   w  w w .j ava 2s  .  c o  m*/
    out.print("A");
    out.print(depth / 2);
    out.print(": n = ");
    out.print(an.n);
    out.print(": ");
    out.print(an.a);
    out.print(": q = ");
    out.print(an.q());
    out.print(", var = ");
    out.print(an.qvar());
    out.print(", 95% = ");
    out.print(2 * Math.sqrt(an.qvar()));
    out.println();
    for (final Map.Entry<Representation<S, F>, StateNode> e : an.m_.entrySet()) {
        printStateNode(e.getValue(), depth + 1, out);
    }
}

From source file:halive.shootinoutside.common.core.game.map.GameMap.java

public void debugMapLayout(PrintStream out) {
    out.println("Map name: " + mapName);
    for (int x = 0; x < width; x++) {
        out.print("X: " + x + " ");
        for (int y = 0; y < height; y++) {
            out.print(tiles[x][y].getTileID() + " ");
        }//from   w ww .j  av  a2 s. c o m
        out.print("\n");
    }
    out.println("Texture Size " + textureSheet.length + " bytes");
}

From source file:edu.umn.cs.spatialHadoop.delaunay.DelaunayTriangulation.java

private static void drawVoronoiDiagram(PrintStream out, Rectangle mbr, Rectangle bigMBR,
        List<Geometry> finalRegions, List<Geometry> nonfinalRegions) {
    Coordinate[] mbrCoords = new Coordinate[5];
    mbrCoords[0] = new Coordinate(bigMBR.x1, bigMBR.y1);
    mbrCoords[1] = new Coordinate(bigMBR.x2, bigMBR.y1);
    mbrCoords[2] = new Coordinate(bigMBR.x2, bigMBR.y2);
    mbrCoords[3] = new Coordinate(bigMBR.x1, bigMBR.y2);
    mbrCoords[4] = mbrCoords[0];//from  w  w  w  . j a  v  a 2s .com
    GeometryFactory factory = new GeometryFactory();
    Polygon bigMBRPoly = factory.createPolygon(factory.createLinearRing(mbrCoords), null);

    out.printf("rectangle %f, %f, %f, %f, :fill=>:none, :stroke=>:black\n", mbr.x1, mbr.y1, mbr.getWidth(),
            mbr.getHeight());

    out.println("group {");
    out.println("group(:fill => :none, :stroke=>:green) {");
    for (Geometry p : finalRegions) {
        Coordinate[] coords = p.getCoordinates();
        out.print("polygon [");
        for (Coordinate c : coords)
            out.printf("%f, %f, ", c.x, c.y);
        out.println("]");
    }
    out.println("}");
    out.println("group(:stroke=>:none, :fill=>:green) {");
    for (Geometry p : finalRegions) {
        Point site = (Point) p.getUserData();
        out.printf("circle %f, %f, 1\n", site.x, site.y);
    }
    out.println("}");
    out.println("}");
    out.println("group {");
    out.println("group(:fill => :none, :strok=>:red) {");
    for (Geometry p : nonfinalRegions) {
        if (!bigMBRPoly.contains(p)) {
            if (p instanceof Polygon) {
                p = p.intersection(bigMBRPoly).getBoundary().difference(bigMBRPoly.getBoundary());
            } else {
                p = p.intersection(bigMBRPoly);
            }
        }
        Coordinate[] coords = p.getCoordinates();
        if (p instanceof Polygon)
            out.print("polygon [");
        else
            out.print("polyline [");
        for (Coordinate c : coords)
            out.printf("%f, %f, ", c.x, c.y);
        out.println("]");
    }
    out.println("}");
    out.println("group(:fill => :red, :stroke=>nil) {");
    for (Geometry p : nonfinalRegions) {
        Point site = (Point) p.getUserData();
        out.printf("circle %f, %f, 1\n", site.x, site.y);
    }
    out.println("}");
    out.println("}");
}

From source file:org.eclipse.tycho.extras.docbundle.JavadocRunner.java

public void run() throws Exception {
    this.output.mkdirs();
    this.buildDirectory.mkdirs();

    final File optionsFile = new File(this.buildDirectory, "javadoc.options.txt");
    final Commandline cli = createCommandLine(optionsFile.getAbsolutePath());

    final PrintStream ps = new PrintStream(optionsFile);
    try {//  ww  w.j av a  2s  .  c om
        ps.print(createOptionsFileContent());
        ps.close();

        this.log.info("Calling: " + cli);
        final int rc = CommandLineUtils.executeCommandLine(cli, new DefaultConsumer(), new DefaultConsumer());
        if (rc != 0) {
            if (!this.options.isIgnoreError()) {
                throw new MojoExecutionException("Failed to execute javadoc - rc = " + rc);
            } else {
                this.log.info("execution failed with rc = " + rc);
            }
        }
    } finally {
        ps.close();
    }
}

From source file:io.horizondb.model.core.fields.TimestampField.java

/**    
 * {@inheritDoc}/*from  w w w.jav  a 2  s.co m*/
 */
@Override
public void writePrettyPrint(PrintStream stream) {

    stream.print(this.sourceTimestamp);
    stream.print(' ');
    stream.print(getTimeUnitSymbol(this.sourceUnit));
}

From source file:playground.christoph.evacuation.analysis.AgentsInEvacuationAreaActivityWriter.java

/**
 * Writes the gathered data tab-separated into a text stream.
 *
 * @param stream The data stream where to write the gathered data.
 *///w  w  w .  j a va  2 s . co  m
private void write(PrintStream stream, int[] activities, int[] activitiesParticipatingAtHome,
        int[] activitiesParticipatingNotAtHome, int[] activitiesNotParticipatingAtHome,
        int[] activitiesNotParticipatingNotAtHome) {

    stream.print("time\t"); // hh:mm:ss
    stream.print("time\t"); // ss
    stream.print("all activities\t");
    stream.print("home activities of participating people\t");
    stream.print("home activities of not participating people\t");
    stream.print("other activities of participating people\t");
    stream.print("other activities of not participating people");

    // end of header
    stream.print("\n");

    for (int i = 0; i < activities.length; i++) {

        stream.print(Time.writeTime(i * this.binSize));
        stream.print("\t" + i * this.binSize);

        stream.print("\t" + activities[i]);
        stream.print("\t" + activitiesParticipatingAtHome[i]);
        stream.print("\t" + activitiesParticipatingNotAtHome[i]);
        stream.print("\t" + activitiesNotParticipatingAtHome[i]);
        stream.print("\t" + activitiesNotParticipatingNotAtHome[i]);

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

From source file:com.amazonaws.eclipse.sdk.ui.wizard.NewAwsJavaProjectWizard.java

private void addSamplesToProject() throws CoreException, IOException {
    IProject project = pageTwo.getJavaProject().getProject();
    IPath workspaceRoot = project.getWorkspace().getRoot().getRawLocation();
    IPath srcPath = workspaceRoot.append(project.getFullPath()).append("src");

    AccountInfo selectedAccount = pageOne.getSelectedAccount();

    for (SdkSample sample : pageOne.getSelectedSamples()) {
        for (File sampleSourceFile : sample.getPath().toFile()
                .listFiles(new FilenameFilters.JavaSourceFilenameFilter())) {
            String sampleContent = FileUtils.readFileToString(sampleSourceFile);

            if (selectedAccount != null) {
                sampleContent = updateSampleContentWithConfiguredProfile(sampleContent, selectedAccount);
            }/*from w  w w.j a v a  2s .  c o  m*/

            IFileStore projectSourceFolderDestination = EFS.getLocalFileSystem()
                    .fromLocalFile(srcPath.append(sampleSourceFile.getName()).toFile());
            PrintStream ps = new PrintStream(
                    projectSourceFolderDestination.openOutputStream(EFS.OVERWRITE, null));
            ps.print(sampleContent);
            ps.close();
        }
    }
}

From source file:com.tamingtext.tagrecommender.TestStackOverflowTagger.java

/** Dump the overall metrics */
public void dumpStats(PrintStream out, int postCount, int totalSingleCorrect, int totalHalfCorrect) {
    out.println("evaluated " + postCount + " posts; " + totalSingleCorrect + " with one correct tag, "
            + totalHalfCorrect + " with half correct");

    out.print("\t %single correct: " + nf.format((totalSingleCorrect * 100) / (float) postCount));
    out.println(", %half correct: " + nf.format((totalHalfCorrect * 100) / (float) postCount));
    out.println();//w  ww .  j  a v  a  2s.co m
    out.flush();
}