List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:com.ruizhan.hadoop.hdfs.FsShell.java
private void printInstanceUsage(PrintStream out, Command instance) { out.println(usagePrefix + " " + instance.getUsage()); }
From source file:client.communication.SocketClient.java
/** * Envia a mensagem para o servidor e retorna a resposta * /*from w w w .j a va 2 s. c o m*/ * @param message * @return */ public String sendMessage(String message) { Socket socket = null; PrintStream stream = null; try { socket = new Socket(serverAddress, serverPort); stream = new PrintStream(socket.getOutputStream()); // Envia requisiao stream.println(message); // L resposta socket.getInputStream().read(response); } catch (IOException e) { System.out.println("Problem connecting server!"); } finally { try { // Fecha stream if (stream != null) stream.close(); if (socket != null) socket.close(); } catch (IOException e) { System.err.println("Problem closing socket: " + e.getMessage()); } } // Decodifica resposta em base 64 String _reply = new String(Base64.decodeBase64(response)); // Remove o espao nas extremidades da string de resposta return _reply.trim(); }
From source file:iristk.cfg.ABNFGrammar.java
@Override public void marshal(OutputStream out) { PrintStream ps = new PrintStream(out); ps.println("#ABNF 1.0 UTF-8;\n"); if (getLanguage() != null) ps.println("language " + getLanguage() + ";"); if (getRoot() != null) ps.println("root $" + getRoot() + ";"); ps.println();/*from w ww .j a v a 2 s . c om*/ for (Object rule : getRules()) { if (isPublic(rule)) ps.print("public "); ps.println("$" + getRuleId(rule) + " = " + matchToString(this, getMatches(rule)) + ";"); ps.println(); } }
From source file:hu.bme.mit.sette.RunnerUI.java
public void run(BufferedReader in, PrintStream out) throws Exception { // directories File snippetProjectDir = runner.getSnippetProjectSettings().getBaseDirectory(); File runnerProjectDir = runner.getRunnerProjectSettings().getBaseDirectory(); out.println("Snippet project: " + snippetProjectDir); out.println("Runner project: " + runnerProjectDir); try {//from w w w .j a v a 2s. c om // run tool on code snippets out.println("Clean up"); runner.cleanUp(); out.println("Press [Enter] to start execution"); in.readLine(); out.println("Clean up"); runner.cleanUp(); out.println("Starting run"); runner.run(out); out.println("Run successful"); } catch (Exception e) { out.println("Run failed: " + e.getMessage()); e.printStackTrace(); } }
From source file:hudson.plugins.clearcase.action.AbstractCheckoutAction.java
protected AbstractCheckoutAction.LoadRulesDelta getLoadRulesDelta(Set<String> configSpecLoadRules, Launcher launcher) {/* w w w. jav a 2 s . c o m*/ Set<String> removedLoadRules = new LinkedHashSet<String>(configSpecLoadRules); Set<String> addedLoadRules = new LinkedHashSet<String>(); if (!ArrayUtils.isEmpty(loadRules)) { for (String loadRule : loadRules) { addedLoadRules.add(ConfigSpec.cleanLoadRule(loadRule, launcher.isUnix())); } removedLoadRules.removeAll(addedLoadRules); addedLoadRules.removeAll(configSpecLoadRules); PrintStream logger = launcher.getListener().getLogger(); for (String removedLoadRule : removedLoadRules) { logger.println("Removed load rule : " + removedLoadRule); } for (String addedLoadRule : addedLoadRules) { logger.println("Added load rule : " + addedLoadRule); } } return new AbstractCheckoutAction.LoadRulesDelta(removedLoadRules, addedLoadRules); }
From source file:net.sf.vntconverter.VntConverter.java
/** * Enkodiert eine UTF-8-Textdatei in eine vNote-Datei. *//*from w w w . j av a2s.c o m*/ private void encode(File in, File out) { PrintStream ps = null; try { ps = new PrintStream(out, "UTF-8"); ps.println("BEGIN:VNOTE"); ps.println("VERSION:1.1"); String content = getFileContent(in); String encodedContent = "BODY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:" + encode(content); while (encodedContent.length() > 0) { if (encodedContent.length() > 74) { ps.println(encodedContent.substring(0, 74) + "="); encodedContent = encodedContent.substring(74); } else { ps.println(encodedContent); encodedContent = ""; } } String lastModified = VNT_DATE_FORMAT.format(new Date(out.lastModified())); ps.println("DCREATED:" + lastModified); ps.println("LAST-MODIFIED:" + lastModified); ps.println("END:VNOTE"); } catch (Exception e) { throw new RuntimeException("Exception caught in VntConverter.encode(in, out):", e); } finally { if (ps != null) { ps.close(); } } }
From source file:de.tsystems.mms.apm.performancesignature.dynatrace.PerfSigStopRecording.java
@Override public void perform(@Nonnull final Run<?, ?> run, @Nonnull final FilePath workspace, @Nonnull final Launcher launcher, @Nonnull final TaskListener listener) throws InterruptedException, IOException { PrintStream logger = listener.getLogger(); DTServerConnection connection = PerfSigUtils.createDTServerConnection(dynatraceProfile); logger.println(Messages.PerfSigStopRecording_StoppingSessionRecording()); final List<PerfSigEnvInvisAction> envVars = run.getActions(PerfSigEnvInvisAction.class); PerfSigEnvInvisAction buildEnvVars = null; Date timeframeStart = null;/*from w w w . j a v a 2 s. co m*/ if (!envVars.isEmpty()) { buildEnvVars = envVars.get(envVars.size() - 1); timeframeStart = buildEnvVars.getTimeframeStart(); } String sessionName; if (timeframeStart != null) { Date timeframeStop = new Date(); logger.println(Messages.PerfSigStopRecording_TimeframeStart(timeframeStart)); logger.println(Messages.PerfSigStopRecording_TimeframeStop(timeframeStop)); sessionName = connection.storePurePaths(buildEnvVars.getSessionName(), timeframeStart, timeframeStop, PerfSigStartRecording.DescriptorImpl.defaultRecordingOption, PerfSigStartRecording.DescriptorImpl.defaultLockSession, false); } else { sessionName = connection.stopRecording(); } if (StringUtils.isBlank(sessionName)) { throw new RESTErrorException(Messages.PerfSigStopRecording_InternalError()); } if (buildEnvVars != null) { buildEnvVars.setSessionName(sessionName); } logger.println(Messages.PerfSigStopRecording_StoppedSessionRecording( connection.getCredProfilePair().getProfile(), sessionName)); if (getReanalyzeSession()) { logger.println(Messages.PerfSigStopRecording_ReanalyzeSession()); boolean reanalyzeFinished = connection.reanalyzeSessionStatus(sessionName); if (connection.reanalyzeSession(sessionName)) { int timeout = reanalyzeSessionTimeout; while ((!reanalyzeFinished) && (timeout > 0)) { logger.println(Messages.PerfSigStopRecording_QueryingSession()); Thread.sleep(reanalyzeSessionPollingInterval); timeout -= reanalyzeSessionPollingInterval; reanalyzeFinished = connection.reanalyzeSessionStatus(sessionName); } if (reanalyzeFinished) { logger.println(Messages.PerfSigStopRecording_SessionReanalysisFinished()); } else { throw new RESTErrorException(Messages.PerfSigStopRecording_TimeoutRaised()); } } } }
From source file:com.mockey.ui.HistoryHtmlServlet.java
/** * /* ww w .j a va2 s .c om*/ */ public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { StringBuffer returnHTML = new StringBuffer(); Long fulfilledRequestId = null; try { fulfilledRequestId = new Long(req.getParameter("fulfilledRequestId")); FulfilledClientRequest fCRequest = store.getFulfilledClientRequestsById(fulfilledRequestId); String contextRootScenarioURL = Url.getContextAwarePath("/scenario", req.getContextPath()); returnHTML.append("<script type=\"text/javascript\">"); returnHTML.append("$(document).ready(function() {"); returnHTML.append(" $('textarea.resizable:not(.processed)').TextAreaResizer();"); returnHTML.append(" $('iframe.resizable:not(.processed)').TextAreaResizer();"); returnHTML.append("});"); returnHTML.append("</script>"); returnHTML.append("<table class=\"history\" width=\"100%\">"); returnHTML.append(" <tbody>"); returnHTML.append("<tr>"); returnHTML.append("<td>"); returnHTML.append("<div class=\"conflict_message\">"); String contextRoot = req.getContextPath(); String doitagainUrl = Url.getContextAwarePath("/doitagain", contextRoot); returnHTML.append("<form id=\"child\" action=\"" + doitagainUrl + "\" method=\"post\" style=\"background-color:#FFD7D7\" >"); returnHTML.append("<input type=\"hidden\" name=\"fulfilledClientRequestId\" value=\"" + fCRequest.getId() + "\" />"); returnHTML.append("<h2>Request:</h2>"); returnHTML.append("<p><h4>" + fCRequest.getRawRequest() + "</h4></p>"); returnHTML.append("<p>Header (pipe delimited)</p>"); returnHTML.append("<p><textarea class=\"resizable\" name=\"requestHeader\" rows=\"5\" cols=\"100%\">" + fCRequest.getClientRequestHeaders() + "</textarea></p>"); returnHTML.append("<p>Parameters (pipe delimited)</p>"); returnHTML .append("<p><textarea class=\"resizable\" name=\"requestParameters\" rows=\"5\" cols=\"100%\">" + fCRequest.getClientRequestParameters() + "</textarea></p>"); returnHTML.append("<p>Body</p>"); returnHTML.append("<p><textarea class=\"resizable\" name=\"requestBody\" rows=\"10\" >" + fCRequest.getClientRequestBody() + "</textarea></p>"); returnHTML.append( "<input type=\"submit\" name=\"NewParameters\" value=\"Send This Again\" class=\"button\" />"); returnHTML .append(" This will build a request with the body, parameters, and header information above. "); returnHTML.append("</form>"); returnHTML.append("</div>"); returnHTML.append("</td>"); returnHTML.append("</tr>"); returnHTML.append(" <tr>"); returnHTML.append("<td >"); returnHTML.append("<form id=\"child\" action=\"" + contextRootScenarioURL + "\" method=\"post\">"); returnHTML.append("<input type=\"hidden\" name=\"actionTypeGetFlag\" value=\"true\" />"); returnHTML.append( "<input type=\"hidden\" name=\"serviceId\" value=\"" + fCRequest.getServiceId() + "\" />"); returnHTML.append( "<div id=\"scenario" + fCRequest.getId() + "\" class=\"addition_message mockeyResponse\">"); returnHTML.append("<h2>Response: </h2>"); returnHTML.append("<p>Status</p>"); returnHTML.append("<p>"); returnHTML.append(" <textarea class=\"resizable\" name=\"responseStatus\" rows=\"1\" >" + fCRequest.getResponseMessage().getHttpResponseStatusCode() + "</textarea>"); returnHTML.append("</p>"); returnHTML.append("<p>Header</p>"); returnHTML.append("<p>"); returnHTML.append("<textarea class=\"resizable\" name=\"responseHeader\" rows=\"10\" >" + fCRequest.getResponseMessage().getHeaderInfo() + "</textarea>"); returnHTML.append("</p>"); returnHTML.append("<p>Body</p>"); returnHTML.append("<p>"); returnHTML.append( "<textarea style=\"margin-top: 0px;\" name=\"responseMessage\" class=\"resizable responseContent\" rows=\"10\" >" + StringEscapeUtils.escapeXml(fCRequest.getResponseMessage().getBody()) + "</textarea>"); returnHTML.append("</p>"); returnHTML.append("<p>"); returnHTML.append("<input type=\"submit\" name=\"Save\" value=\"Save Response as a Scenario\" />"); String inspectFulfilledRequestURL = Url.getContextAwarePath("/inspect", req.getContextPath()); returnHTML.append(" View response body as: "); returnHTML.append("<a href=\"" + inspectFulfilledRequestURL + "?content_type=text/xml;&fulfilledRequestId=" + fulfilledRequestId + "\">XML</a> "); returnHTML.append("<a href=\"" + inspectFulfilledRequestURL + "?content_type=text/plain;&fulfilledRequestId=" + fulfilledRequestId + "\">Plain</a> "); returnHTML.append("<a href=\"" + inspectFulfilledRequestURL + "?content_type=text/css;&fulfilledRequestId=" + fulfilledRequestId + "\">CSS</a> "); returnHTML.append("<a href=\"" + inspectFulfilledRequestURL + "?content_type=application/json;&fulfilledRequestId=" + fulfilledRequestId + "\">JSON</a> "); String encoded = URLEncoder.encode("text/html;charset=utf-8", "utf-8"); returnHTML.append("<a href=\"" + inspectFulfilledRequestURL + "?content_type=" + encoded + "&fulfilledRequestId=" + fulfilledRequestId + "\">HTML</a> "); returnHTML.append("</p>"); returnHTML.append("</form>"); returnHTML.append("</div>"); returnHTML.append("</td>"); returnHTML.append("</tr>"); returnHTML.append("</tbody>"); returnHTML.append("</table>"); // } catch (Exception e) { returnHTML.append("Sorry, history for this request is not available."); } resp.setContentType("text/html"); PrintStream out = new PrintStream(resp.getOutputStream()); out.println(returnHTML.toString()); }
From source file:com.tamingtext.tagrecommender.TestStackOverflowTagger.java
/** Dump the tag metrics */ public void dumpTags(final PrintStream out, final OpenObjectIntHashMap<String> tagCounts, final OpenObjectIntHashMap<String> tagCorrect) { out.println("-- tag\ttotal\tcorrect\tpct-correct --"); tagCounts.forEachPair(new ObjectIntProcedure<String>() { @Override/* w ww . ja v a 2 s . co m*/ public boolean apply(String tag, int total) { int correct = tagCorrect.get(tag); out.println( tag + "\t" + total + "\t" + correct + "\t" + nf.format(((correct * 100) / (float) total))); return true; } }); out.println(); out.flush(); }
From source file:jenkins.plugins.ec2slave.EC2ImageLaunchWrapper.java
public void terminateInstance(PrintStream logger) { logger.println("EC2InstanceComputerLauncher: Terminating EC2 instance [" + curInstanceId + "] ..."); if (testMode) return;//from w w w . j a v a 2s . c o m ec2.terminateInstances(new TerminateInstancesRequest().withInstanceIds(curInstanceId)); }