List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:GenericsTester.java
public void testTypeSafeMaps(PrintStream out) throws IOException { Map<Integer, Integer> squares = new HashMap<Integer, Integer>(); for (int i = 0; i < 100; i++) { squares.put(i, i * i);/*from w w w . j a v a2s .c o m*/ } for (int i = 0; i < 10; i++) { int n = i * 3; out.println("The square of " + n + " is " + squares.get(n)); } }
From source file:com.dubture.jenkins.digitalocean.ComputerLauncher.java
private boolean installJava(final PrintStream logger, final Connection conn) throws IOException, InterruptedException { logger.println("Verifying that java exists"); if (conn.exec("java -fullversion", logger) != 0) { logger.println("Installing Java"); // TODO: Add support for non-debian based java installations // and let the user select the java version if (conn.exec("apt-get update -q && apt-get install -y openjdk-7-jdk", logger) != 0) { logger.println("Failed to download Java"); return false; }//from w w w . j a va 2s. c om } return true; }
From source file:hudson.plugins.blazemeter.BzmBuild.java
public void interrupt(CiBuild build, Master master, PrintStream logger) { if (build != null && master != null) { try {/*from www. ja v a 2 s . c o m*/ boolean hasReport = build.interrupt(master); if (hasReport) { logger.println(BzmJobNotifier.formatMessage("Get reports after interrupt")); build.doPostProcess(master); } } catch (IOException e) { logger.println(BzmJobNotifier.formatMessage("Failed to interrupt build " + e.getMessage())); } } }
From source file:net.morphbank.mbsvc3.webservices.RestService.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // //w ww. jav a 2 s. c om String method = request.getParameter(RequestParams.PARAM_METHOD); PrintStream out = new PrintStream(response.getOutputStream()); try { out.println("<html><body>"); if (RequestParams.METHOD_REMOTE_UPDATE.equals(method)) { UpdateRemote.update(request, response); } else if (RequestParams.METHOD_FIX_UUID.equals(method)) { //TODO call fix uuid and fix id response.setContentType("text/html"); UUIDServices uuidServices = new UUIDServices(out); int noUUIDFixed = uuidServices.fixAllMissingUUIDs(); out.println("<p>No of fixed MissingUUIDs: " + noUUIDFixed + "</p>"); int noIDFixed = uuidServices.fixAllMissingIds(); out.println("<p>No of fixed IDs: " + noIDFixed + "</p>"); } else { // TODO turn over to processrequest response.setContentType("text/xml"); out.println("<p>Here I am</p>"); } } catch (Exception e) { e.printStackTrace(); } finally { out.println("</body></html>"); out.close(); } }
From source file:fr.cs.examples.propagation.TrackCorridor.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)); TimeScale utc = TimeScalesFactory.getUTC(); Propagator propagator;// w w w .ja va 2s. c o m if (parser.containsKey(ParameterKey.TLE_LINE1)) { propagator = createPropagator(parser.getString(ParameterKey.TLE_LINE1), parser.getString(ParameterKey.TLE_LINE2)); } else { propagator = createPropagator(parser.getDate(ParameterKey.ORBIT_CIRCULAR_DATE, utc), parser.getDouble(ParameterKey.ORBIT_CIRCULAR_A), parser.getDouble(ParameterKey.ORBIT_CIRCULAR_EX), parser.getDouble(ParameterKey.ORBIT_CIRCULAR_EY), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_I), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_RAAN), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_ALPHA)); } // simulation properties AbsoluteDate start = parser.getDate(ParameterKey.START_DATE, utc); double duration = parser.getDouble(ParameterKey.DURATION); double step = parser.getDouble(ParameterKey.STEP); double angle = parser.getAngle(ParameterKey.ANGULAR_OFFSET); // set up a handler to gather all corridor points CorridorHandler handler = new CorridorHandler(angle); propagator.setMasterMode(step, handler); // perform propagation, letting the step handler populate the corridor propagator.propagate(start, start.shiftedBy(duration)); // retrieve the built corridor List<CorridorPoint> corridor = handler.getCorridor(); // create a 7 columns csv file representing the corridor in the user home directory, with // date in column 1 (in ISO-8601 format) // left limit latitude in column 2 and left limit longitude in column 3 // center track latitude in column 4 and center track longitude in column 5 // right limit latitude in column 6 and right limit longitude in column 7 DecimalFormat format = new DecimalFormat("#00.00000", new DecimalFormatSymbols(Locale.US)); PrintStream stream = new PrintStream(output); for (CorridorPoint p : corridor) { stream.println(p.getDate() + separator + format.format(FastMath.toDegrees(p.getLeft().getLatitude())) + separator + format.format(FastMath.toDegrees(p.getLeft().getLongitude())) + separator + format.format(FastMath.toDegrees(p.getCenter().getLatitude())) + separator + format.format(FastMath.toDegrees(p.getCenter().getLongitude())) + separator + format.format(FastMath.toDegrees(p.getRight().getLatitude())) + separator + format.format(FastMath.toDegrees(p.getRight().getLongitude()))); } stream.close(); }
From source file:com.github.vatbub.tictactoe.view.AnimationThreadPoolExecutor.java
@SuppressWarnings("unused") public <T> Future<T> submitWaitForUnlock(Callable<T> task) { Callable<T> effectiveTask = () -> { // PrintStreams magically don't make the wait loop hang PrintStream nullStream = new PrintStream(new OutputStream() { public void write(int b) { //DO NOTHING }/*ww w . j av a2s . com*/ }); while (isBlocked()) { nullStream.println("Waiting..."); } // run FutureTask<T> effectiveCall = new FutureTask<>(task); Platform.runLater(effectiveCall); return effectiveCall.get(); }; return super.schedule(effectiveTask, 0, NANOSECONDS); }
From source file:edu.stanford.muse.lens.LensPrefs.java
private void savePrefs() { try {//from w ww .j a v a 2 s. c o m FileOutputStream fos = new FileOutputStream(pathToPrefsFile); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(prefs); oos.flush(); oos.close(); PrintStream ps = new PrintStream(new FileOutputStream(pathToPrefsFile + ".txt")); for (String term : prefs.keySet()) { Map<String, Float> map = prefs.get(term); for (String url : map.keySet()) ps.println(term + "\t" + url + "\t" + map.get(url)); } ps.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.tsystems.mms.apm.performancesignature.dynatrace.PerfSigStartRecording.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); CredProfilePair pair = connection.getCredProfilePair(); logger.println(Messages.PerfSigStartRecording_StartingSession()); String extTestCase = run.getEnvironment(listener).expand(this.testCase); String sessionName = pair.getProfile() + "_" + run.getParent().getName() + "_Build-" + run.getNumber() + "_" + extTestCase;/*w ww. j a va 2 s . c om*/ sessionName = sessionName.replace("/", "_"); for (BaseConfiguration profile : connection.getSystemProfiles()) { SystemProfile systemProfile = (SystemProfile) profile; if (pair.getProfile().equals(systemProfile.getId()) && systemProfile.isRecording()) { logger.println(Messages.PerfSigStartRecording_AnotherSessionStillRecording()); PerfSigStopRecording stopRecording = new PerfSigStopRecording(dynatraceProfile); stopRecording.perform(run, workspace, launcher, listener); break; } } String result; Date timeframeStart = null; try { result = connection.startRecording(sessionName, Messages.PerfSigStartRecording_SessionTriggered(), getRecordingOption(), lockSession, false); } catch (CommandExecutionException e) { if (e.getMessage().contains("continuous")) { timeframeStart = new Date(); result = sessionName; //pass sessionName to buildVars } else throw e; } if (result != null && result.contains(sessionName)) { logger.println(Messages.PerfSigStartRecording_StartedSessionRecording(pair.getProfile(), sessionName)); } else { throw new RESTErrorException(Messages.PerfSigStartRecording_SessionRecordingError(pair.getProfile())); } logger.println(Messages.PerfSigStartRecording_RegisteringTestRun()); String testRunId = connection.registerTestRun(run.getNumber()); if (testRunId != null) { logger.println(Messages.PerfSigStartRecording_StartedTestRun(pair.getProfile(), testRunId)); logger.println(Messages.PerfSigStartRecording_RegisteredTestRunId(testRunId, PerfSigEnvContributor.TESTRUN_ID_KEY, PerfSigEnvContributor.SESSIONCOUNT)); } else { logger.println(Messages.PerfSigStartRecording_CouldNotRegisterTestRun()); } run.addAction(new PerfSigEnvInvisAction(result, timeframeStart, extTestCase, testRunId)); }
From source file:avantssar.aslanpp.testing.TranslationInstance.java
public void report(PrintStream out, int index, List<String> backendNames, boolean odd) { out.print("<tr style='background-color: "); out.print(TranslationReport.BG(odd)); out.println(";'>"); out.println("<td style='text-align: right;'>" + index + "</td>"); out.print("<td"); boolean different = false; boolean differentDet = false; if (aslanPPcheck1 != null || aslanPPcheck2 != null) { try {/* w w w .ja v a 2 s . c om*/ if (aslanPPcheck1 != null && aslanPPcheck2 != null) { different = !FileUtils.contentEquals(aslanPPcheck1, aslanPPcheck2); } else { different = true; } if (aslanPPcheck1det != null && aslanPPcheck2det != null) { differentDet = !FileUtils.contentEquals(aslanPPcheck1det, aslanPPcheck2det); } else { differentDet = aslanPPcheck1det != null || aslanPPcheck2det != null; } out.print(" style='background-color: "); if (different || differentDet) { out.print(TranslationReport.RED(odd)); } else { out.print(TranslationReport.GREEN(odd)); } out.print(";'"); } catch (IOException e) { Debug.logger.error("Failed to compare files '" + aslanPPcheck1.getAbsolutePath() + "' and '" + aslanPPcheck2.getAbsolutePath() + "'.", e); } } out.print(">"); HTMLHelper.fileOrDash(out, outputDir, aslanPPfile, null); // if (different) { // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck1, "pp1"); // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck2, "pp2"); // } // if (differentDet) { // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck1det, "pp1d"); // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck2det, "pp2d"); // } out.println("</td>"); out.print("<td style='background-color: "); if (errors > 0) { out.print(TranslationReport.RED(odd)); } else { out.print(TranslationReport.GREEN(odd)); } out.print(";'>"); HTMLHelper.fileOrDash(out, outputDir, errorsFile, errors > 0 ? Integer.toString(errors) : "-"); out.println("</td>"); out.print("<td style='background-color: "); if (warnings > 0) { out.print(TranslationReport.RED(odd)); } else { out.print(TranslationReport.GREEN(odd)); } out.print(";'>"); HTMLHelper.fileOrDash(out, outputDir, warningsFile, warnings > 0 ? Integer.toString(warnings) : "-"); out.println("</td>"); filesCompared(out, aslanFile, expectedASLanFile, "expected", odd); out.println("<td>" + expectedVerdict.toString() + "</td>"); for (String s : backendNames) { BackendRun br = verdicts.get(s); if (br != null) { br.report(out, odd, expectedVerdict); } else { out.print("<td>-</td>"); } } out.println("</tr>"); }
From source file:edu.kit.dama.staging.util.DataOrganizationUtils.java
/** * Print the provided FileTree into the provided PrintStream. This method is * intended to be used for debugging.//from www .ja v a2s . com * * @param pTree The FileTree to print. * @param pIncludeURL Include URL after filenames. * @param pOut The PrintStream to which the output is written, e.g. * System.out. */ public static void printTree(ICollectionNode pTree, boolean pIncludeURL, PrintStream pOut) { if (pOut == null) { throw new IllegalArgumentException("Argument pOut must not be null"); } StringBuilder b = new StringBuilder(); printTreeInternal(pTree, "", b, false, pIncludeURL); pOut.println(b.toString()); }