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.os.windows.ManagedWindowsServiceLauncher.java

private void copySlaveJar(PrintStream logger, SmbFile remoteRoot) throws IOException {
    // copy slave.jar
    logger.println("Copying slave.jar");
    copyAndClose(Hudson.getInstance().getJnlpJars("slave.jar").getURL().openStream(),
            new SmbFile(remoteRoot, "slave.jar").getOutputStream());
}

From source file:ca.nines.ise.cmd.Syntax.java

/**
 * {@inheritDoc}/*from   w w w . j  a va  2  s . com*/
 */
@Override
public void execute(CommandLine cmd) throws Exception {
    File[] files;

    Log log = Log.getInstance();
    Locale.setDefault(Locale.ENGLISH);
    PrintStream out = new PrintStream(System.out, true, "UTF-8");

    if (cmd.hasOption("l")) {
        out = new PrintStream(new FileOutputStream(cmd.getOptionValue("l")), true, "UTF-8");
    }

    files = getFilePaths(cmd);
    out.println("Found " + files.length + " files to check.");
    for (File file : files) {
        DOM dom = new DOMBuilder(file).build();
        if (log.count() > 0) {
            out.println(log);
            log.clear();
        }
    }
}

From source file:cz.zcu.kiv.eegdatabase.logic.csv.SimpleCSVFactory.java

/**
 * Generating csv file from scenarios// ww  w.jav a2s.  co  m
 *
 * @return csv file with scenarios
 * @throws IOException - error writing to stream
 */
@Transactional(readOnly = true)
public OutputStream generateScenariosCsvFile() throws IOException {

    log.debug("Creating output stream");
    OutputStream out = new ByteArrayOutputStream();
    PrintStream printStream = new PrintStream(out);
    List<Scenario> scenarioList = scenarioDao.getAllRecords();
    log.debug("Creating table header");
    printStream.println(
            CSVUtils.SCENARIO_TITLE + CSVUtils.SEMICOLON + CSVUtils.SCENARIO_LENGTH + CSVUtils.SEMICOLON
                    + CSVUtils.SCENARIO_DESCRIPTION + CSVUtils.SEMICOLON + CSVUtils.SCENARIO_DETAILS);
    log.debug("Printing experiments to outputstream");
    for (int i = 0; i < scenarioList.size(); i++) {
        printStream.println(scenarioList.get(i).getTitle() + CSVUtils.SEMICOLON
                + scenarioList.get(i).getScenarioLength() + CSVUtils.SEMICOLON
                + scenarioList.get(i).getDescription() + CSVUtils.SEMICOLON + CSVUtils.PROTOCOL_HTTP + domain
                + CSVUtils.SCENARIO_URL + scenarioList.get(i).getScenarioId());
    }
    printStream.close();

    return out;
}

From source file:de.tudarmstadt.ukp.clarin.webanno.brat.curation.AgreementUtils.java

public static void dumpAgreementStudy(PrintStream aOut, AgreementResult aAgreement) {
    try {//ww w. j  a v  a  2  s.c o m
        aOut.printf("Category count: %d%n", aAgreement.getStudy().getCategoryCount());
    } catch (Throwable e) {
        aOut.printf("Category count: %s%n", ExceptionUtils.getRootCauseMessage(e));
    }
    try {
        aOut.printf("Item count: %d%n", aAgreement.getStudy().getItemCount());
    } catch (Throwable e) {
        aOut.printf("Item count: %s%n", ExceptionUtils.getRootCauseMessage(e));
    }

    List<ConfigurationSet> completeSets = aAgreement.getCompleteSets();
    int i = 0;
    for (ICodingAnnotationItem item : aAgreement.getStudy().getItems()) {
        StringBuilder sb = new StringBuilder();
        sb.append(completeSets.get(i).getPosition());
        for (IAnnotationUnit unit : item.getUnits()) {
            if (sb.length() > 0) {
                sb.append(" \t");
            }
            sb.append(unit.getCategory());
        }
        aOut.println(sb);
        i++;
    }
}

From source file:com.dubture.jenkins.digitalocean.ComputerLauncher.java

private Connection getDropletConnection(String host, int port, PrintStream logger) throws IOException {
    logger.println("Connecting to " + host + " on port " + port + ". ");
    Connection conn = new Connection(host, port);
    try {/*from  w ww. j a va2 s. c o m*/
        conn.connect(null, 10 * 1000, 10 * 1000);
    } catch (SocketTimeoutException e) {
        return null;
    }
    logger.println("Connected via SSH.");
    return conn;
}

From source file:hudson.plugins.blazemeter.BzmBuild.java

@Override
public Result call() throws Exception {
    ProxyConfigurator.updateProxySettings(proxyConfiguration, isSlave);
    PrintStream logger = listener.getLogger();
    FilePath wsp = createWorkspaceDir(workspace);
    logger.println(BzmJobNotifier.formatMessage("BlazemeterJenkins plugin v." + Utils.version()));
    JenkinsBlazeMeterUtils utils = createBzmUtils(createLogFile(wsp));
    try {//from  w  w  w  . j  a  va2 s .  c o  m
        build = createCiBuild(utils, wsp);
        try {
            master = build.start();
            if (master != null) {
                String runId = jobName + "-" + buildId + "-" + reportLinkId;
                EnvVars.masterEnvVars.put(runId, master.getId());
                EnvVars.masterEnvVars.put(runId + "-" + master.getId(), build.getPublicReport());
                putLinkName(runId);
                build.waitForFinish(master);
            } else {
                listener.error(BzmJobNotifier.formatMessage("Failed to start test"));
                return Result.FAILURE;
            }
        } catch (InterruptedException e) {
            EnvVars.masterEnvVars.put("isInterrupted-" + jobName + "-" + buildId, "false");
            utils.getLogger().warn("Wait for finish has been interrupted", e);
            interrupt(build, master, logger);
            EnvVars.masterEnvVars.put("isInterrupted-" + jobName + "-" + buildId, "true");
            return Result.ABORTED;
        } catch (Exception e) {
            utils.getLogger().warn("Caught exception while waiting for build", e);
            logger.println(BzmJobNotifier.formatMessage("Caught exception " + e.getMessage()));
            return Result.FAILURE;
        }

        BuildResult buildResult = build.doPostProcess(master);
        return mappedBuildResult(buildResult);
    } finally {
        utils.closeLogger();
    }
}

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

/**
 * Service does a few things, which includes:
 * //from w w  w.j  a  va  2 s .  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");
    String tag = req.getParameter("tag");

    JSONObject jsonObject = new JSONObject();
    try {

        // PERFORM ACTION (OPTIONAL)
        if ("filter_tag_on".equals(action)) {
            // Redirect to Home and SET as session FILTER, your tags.
            store.setGlobalStateSystemFilterTag(tag);

            jsonObject.put("success", "Filter by tag is on.");
        } else if ("filter_tag_off".equals(action)) {
            // Redirect to Home and SET as session FILTER, your tags.
            store.setGlobalStateSystemFilterTag(null);
            jsonObject.put("success", "Filter by tag is off.");
        } else if ("filter_status".equals(action)) {
            // Redirect to Home and SET as session FILTER, your tags.
            String filter = (String) req.getSession().getAttribute(FILTER_TAG);
            if (filter != null && filter.trim().length() > 0) {
                jsonObject.put("filter", filter.trim());
                jsonObject.put("status", "on");
            } else {
                jsonObject.put("filter", "");
                jsonObject.put("status", "off");
            }
        } else if ("delete_tag_from_store".equals(action)) {
            store.deleteTagFromStore(tag);
            jsonObject.put("success", "Deleted tag from all things.");

        } else if ("delete_tag_from_service".equals(action)) {
            Service service = store.getServiceById(new Long(serviceId));

            service.removeTagFromList(tag);
            store.saveOrUpdateService(service);
            jsonObject.put("success", "Deleted tag from Service.");

        } else if ("delete_tag_from_service_plan".equals(action)) {
            ServicePlan servicePlan = store.getServicePlanById(new Long(servicePlanId));

            servicePlan.removeTagFromList(tag);
            store.saveOrUpdateServicePlan(servicePlan);

            jsonObject.put("success", "Deleted tag from Service Plan.");

        } else if ("delete_tag_from_scenario".equals(action)) {
            Service service = store.getServiceById(new Long(serviceId));

            Scenario scenario = service.getScenario(new Long(scenarioId));
            scenario.removeTagFromList(tag);
            service.saveOrUpdateScenario(scenario);
            store.saveOrUpdateService(service);
            jsonObject.put("success", "Deleted tag from Scenario.");

        } else if ("update_service_tag".equals(action)) {
            Service service = store.getServiceById(new Long(serviceId));

            service.clearTagList();
            service.addTagToList(tag);
            store.saveOrUpdateService(service);
            jsonObject.put("success", "Updated tag(s) for this Service.");

        } else if ("update_scenario_tag".equals(action)) {
            Service service = store.getServiceById(new Long(serviceId));

            Scenario scenario = service.getScenario(new Long(scenarioId));
            scenario.clearTagList();
            scenario.addTagToList(tag);
            service.saveOrUpdateScenario(scenario);
            store.saveOrUpdateService(service);
            jsonObject.put("success", "Updated tag(s) for this Scenario.");

        }

        // PRESENT STATE
        //
        // OK, now that things are up to date (if any action occurred),
        // let's present the state in the JSON
        // Why get the Service again? Because, we could have removed/edited
        // the tag information from one of the steps above.
        if (serviceId != null) {
            Service service = store.getServiceById(new Long(serviceId));
            jsonObject.put("serviceId", "" + serviceId);

            if (scenarioId != null) {
                Scenario scenario = service.getScenario(new Long(scenarioId));
                jsonObject.put("scenarioId", "" + scenario.getId());
                jsonObject.put("tag", "" + scenario.getTag());
            } else {
                jsonObject.put("tag", "" + service.getTag());
            }
        }

    } catch (Exception e) {
        logger.debug("Unable to manage tag '" + tag + "' 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.panet.imeta.shared.SharedObjects.java

public void saveToFile() throws IOException, KettleException {
    OutputStream outputStream = KettleVFS.getOutputStream(filename, false);

    PrintStream out = new PrintStream(outputStream);

    out.print(XMLHandler.getXMLHeader(Const.XML_ENCODING));
    out.println("<" + XML_TAG + ">");

    Collection<SharedObjectInterface> collection = objectsMap.values();
    for (SharedObjectInterface sharedObject : collection) {
        out.println(sharedObject.getXML());
    }/*  ww  w. j a v  a2 s  .c  om*/

    out.println("</" + XML_TAG + ">");

    out.flush();
    out.close();
    outputStream.close();
}

From source file:ezbake.deployer.publishers.local.BaseLocalPublisher.java

private void inheritIO(final InputStream src, final PrintStream dest) {
    new Thread(new Runnable() {
        public void run() {
            Scanner sc = new Scanner(src);
            while (sc.hasNextLine()) {
                dest.println(sc.nextLine());
            }//from  w  w  w  . ja v  a2 s .  c  om
        }
    }).start();
}

From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java

@Test
public void testLogGreaterThanBuffer() throws Exception {
    PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.INFO));
    StringBuffer sb = new StringBuffer();
    while (sb.length() < 2048) {
        sb.append(TEXT);/*w  w w .  j  a v a 2s . c  om*/
    }
    out.println(sb.toString());
    out.flush();
    out.close();
}