Example usage for java.io PrintStream println

List of usage examples for java.io PrintStream println

Introduction

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

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminate the line.

Usage

From source file:hudson.plugins.clearcase.changelog.UcmChangeLogSet.java

protected void printFile(PrintStream stream, hudson.plugins.clearcase.objects.AffectedFile file) {
    stream.println("\t\t<file>");
    stream.println("\t\t\t<name>" + escapeXml(file.getName()) + "</name>");
    stream.println("\t\t\t<date>" + escapeXml(file.getDateStr()) + "</date>");
    stream.println("\t\t\t<comment>" + escapeXml(file.getComment()) + "</comment>");
    stream.println("\t\t\t<version>" + escapeXml(file.getVersion()) + "</version>");
    stream.println("\t\t\t<event>" + escapeXml(file.getEvent()) + "</event>");
    stream.println("\t\t\t<operation>" + escapeXml(file.getOperation()) + "</operation>");
    stream.println("\t\t</file>");
}

From source file:de.tsystems.mms.apm.performancesignature.PerfSigStopRecording.java

@Override
public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener)
        throws InterruptedException, IOException {
    final PrintStream logger = listener.getLogger();

    logger.println(Messages.PerfSigStopRecording_StopSessionRecording());
    DynatraceServerConfiguration serverConfiguration = PerfSigUtils.getServerConfiguration(dynatraceProfile);
    if (serverConfiguration == null)
        throw new AbortException("failed to lookup Dynatrace server configuration");

    CredProfilePair pair = serverConfiguration.getCredProfilePair(dynatraceProfile);
    if (pair == null)
        throw new AbortException("failed to lookup Dynatrace server profile");

    final DTServerConnection connection = new DTServerConnection(serverConfiguration, pair);

    String sessionName = connection.stopRecording();
    if (StringUtils.isBlank(sessionName))
        throw new RESTErrorException(Messages.PerfSigStopRecording_InternalError());
    logger.println(//w  w  w .j a v  a2 s.co m
            String.format("stopped recording on %s with SessionName %s", pair.getProfile(), sessionName));

    if (getReanalyzeSession()) {
        logger.println("reanalyze session ...");
        boolean reanalyzeFinished = connection.reanalyzeSessionStatus(sessionName);
        if (connection.reanalyzeSession(sessionName)) {
            int timeout = reanalyzeSessionTimeout;
            while ((!reanalyzeFinished) && (timeout > 0)) {
                logger.println("querying session analysis status");
                try {
                    Thread.sleep(reanalyzeSessionPollingInterval);
                    timeout -= reanalyzeSessionPollingInterval;
                } catch (InterruptedException ignored) {
                }
                reanalyzeFinished = connection.reanalyzeSessionStatus(sessionName);
            }
            if (reanalyzeFinished) {
                logger.println("session reanalysis finished");
            } else {
                throw new RESTErrorException("Timeout raised");
            }
        }
    }
    return true;
}

From source file:com.mockey.ui.LatestHistoryAjaxServlet.java

/**
 * Returns the latest conversation sent to the spoofer. If tags are specified, returns the latest conversation
 * matching the given tags./*from  w  w  w  . ja  va2 s .  c o m*/
 */
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    JSONObject jsonObject = new JSONObject();
    try {
        List<FulfilledClientRequest> fCRequests;
        String filterTokensParameter = req.getParameter("tag");
        if (filterTokensParameter != null) {
            HistoryFilter historyFilter = new HistoryFilter();
            historyFilter.addTokens(filterTokensParameter.split(" "));
            fCRequests = store.getFulfilledClientRequest(historyFilter.getTokens());
        } else {
            fCRequests = store.getFulfilledClientRequests();
        }
        if (!fCRequests.isEmpty()) {
            // Get the last one
            FulfilledClientRequest fCRequest = fCRequests.get(fCRequests.size() - 1);
            jsonObject.put("serviceId", fCRequest.getServiceId());
            jsonObject.put("serviceName", fCRequest.getServiceName());
            jsonObject.put("requestUrl", fCRequest.getRawRequest());
            jsonObject.put("requestHeaders", fCRequest.getClientRequestHeaders());
            jsonObject.put("requestParameters", fCRequest.getClientRequestParameters());
            jsonObject.put("requestBody", fCRequest.getClientRequestBody());
            jsonObject.put("requestCookies", fCRequest.getClientRequestCookies());
            jsonObject.put("responseCookies", fCRequest.getClientResponseCookies());
            jsonObject.put("responseStatus", fCRequest.getResponseMessage().getHttpResponseStatusCode());
            jsonObject.put("responseHeader", fCRequest.getResponseMessage().getHeaderInfo());
            jsonObject.put("responseBody", fCRequest.getResponseMessage().getBody());
            jsonObject.put("responseScenarioName", fCRequest.getScenarioName());
            jsonObject.put("responseScenarioTags", fCRequest.getScenarioTagsAsString());
        } else {
            jsonObject.put("error", "No history for given tags");
        }
    } catch (Exception e) {
        logger.error("error encountered while getting history", e);
        try {
            jsonObject.put("error", "History for the latest conversation is not available.");
        } catch (JSONException e1) {
            logger.error("Unable to create JSON", e1);
        }
    }

    resp.setContentType("application/json");

    PrintStream out = new PrintStream(resp.getOutputStream());

    out.println(jsonObject.toString());
}

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

@Override
public void write(final PrintStream ps, final Iterable<S> population) {
    if (population == null) {
        ps.println("No population.");
        return;// ww  w  . ja v  a 2 s . co m
    }

    Integer size = null;
    if (population instanceof Collection<?>) {
        size = ((Collection<S>) population).size();
    }

    ps.println("Population with " + size != null ? size + " " : "" + "solution(s):");
    int solutionNr = 1;
    for (final Solution solution : population) {
        ps.println("\n------------------");
        ps.println("Solution " + solutionNr++ + size != null ? "/" + size : "");
        ps.println("------------------");
        getSolutionPrinter().write(ps, CastUtil.asClass(solution, solutionClazz));
    }
}

From source file:fr.cs.examples.propagation.VisibilityCircle.java

private void run(final File input, final File output, final String separator)
        throws IOException, IllegalArgumentException, OrekitException {

    // read input parameters
    KeyValueFileParser<ParameterKey> parser = new KeyValueFileParser<ParameterKey>(ParameterKey.class);
    parser.parseInput(new FileInputStream(input));

    double minElevation = parser.getAngle(ParameterKey.MIN_ELEVATION);
    double radius = Constants.WGS84_EARTH_EQUATORIAL_RADIUS
            + parser.getDouble(ParameterKey.SPACECRAFT_ALTITUDE);
    int points = parser.getInt(ParameterKey.POINTS_NUMBER);

    // station properties
    double latitude = parser.getAngle(ParameterKey.STATION_LATITUDE);
    double longitude = parser.getAngle(ParameterKey.STATION_LONGITUDE);
    double altitude = parser.getDouble(ParameterKey.STATION_ALTITUDE);
    String name = parser.getString(ParameterKey.STATION_NAME);

    // compute visibility circle
    List<GeodeticPoint> circle = computeCircle(latitude, longitude, altitude, name, minElevation, radius,
            points);//  www .j a  v  a2 s  .co m

    // create a 2 columns csv file representing the visibility circle
    // in the user home directory, with latitude in column 1 and longitude in column 2
    DecimalFormat format = new DecimalFormat("#00.00000", new DecimalFormatSymbols(Locale.US));
    PrintStream csvFile = new PrintStream(output);
    for (GeodeticPoint p : circle) {
        csvFile.println(format.format(FastMath.toDegrees(p.getLatitude())) + ","
                + format.format(FastMath.toDegrees(p.getLongitude())));
    }
    csvFile.close();

}

From source file:com.redhat.rhn.manager.satellite.ConfigureCertificateCommand.java

protected void writeStringToFile() throws FileNotFoundException {
    String tmpDir = System.getProperty("java.io.tmpdir");

    this.certificateFileName = tmpDir + "/cert_text" + RandomStringUtils.randomAlphanumeric(13) + ".cert";

    FileOutputStream out = new FileOutputStream(this.certificateFileName);
    PrintStream printer = new PrintStream(out);
    try {//w w  w. j a v a2 s  .  c o m
        printer.println(this.certificateText);
    } finally {
        printer.close();
    }
}

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];// w  ww.j a v a 2s .  co m
    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:web.GeneratedBanner.java

private void printApplicationName(PrintStream out, Environment environment, Class<?> sourceClass) {
    String banner = generateBanner(environment, sourceClass);
    out.println(banner);
}

From source file:com.mockey.ui.LastVisitTagHelperServlet.java

/**
 * Service does a few things, which includes:
 * //from   ww  w .j  a  v a2s. c o m
 */
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    String serviceId = req.getParameter("serviceId");
    String servicePlanId = req.getParameter("servicePlanId");
    String scenarioId = req.getParameter("scenarioId");
    String action = req.getParameter("action");

    JSONObject jsonObject = new JSONObject();
    try {
        if ("clear_last_visit".equalsIgnoreCase(action)) {
            if (serviceId != null && scenarioId != null) {
                Service service = store.getServiceById(new Long(serviceId));
                Scenario scenario = service.getScenario(new Long(scenarioId));
                scenario.setLastVisit(null);
                service.saveOrUpdateScenario(scenario);
                store.saveOrUpdateService(service);

            } else if (serviceId != null) {
                Service service = store.getServiceById(new Long(serviceId));
                service.setLastVisit(null);
                store.saveOrUpdateService(service);
            } else if (servicePlanId != null) {
                ServicePlan servicePlan = store.getServicePlanById(new Long(servicePlanId));
                servicePlan.setLastVisit(null);
                store.saveOrUpdateServicePlan(servicePlan);
            }

            jsonObject.put("success", "Last visit was cleared.");
        } else {
            jsonObject.put("info", "Hmm...you seem to be missing some things. ");
        }

    } catch (Exception e) {
        logger.debug("Unable to clear last visit time with action '" + action + "' :" + e.getMessage());
        try {
            jsonObject.put("error", "" + "Sorry, not available.");
        } catch (JSONException e1) {
            logger.debug("What happended?" + e1.getMessage());
        }
    }

    resp.setContentType("application/json");

    PrintStream out = new PrintStream(resp.getOutputStream());

    out.println(jsonObject.toString());

    return;
}

From source file:com.moscona.dataSpace.ExportHelper.java

private void csvOut(PrintStream out, String key, String value) {
    out.println(excelQuote(key) + "," + excelQuote(value));
}