List of usage examples for java.io PrintWriter println
public void println(Object x)
From source file:duty_scheduler.Scheduler.java
/** * Prints the results of the algorithm to a file * /*from w w w . ja va 2s. co m*/ * @param best The best Schedule found during the run * @param runTimeReport A String describing the runtime of the algorithm */ private static void printResults(Schedule best, String runTimeReport) { String resultsFile = "schedule_" + (new SimpleDateFormat("MM-dd-yyyy-hh:mm")).format(new Date()) + ".sched"; PrintWriter dataOut = null; try { dataOut = new PrintWriter(resultsFile); dataOut.println(runTimeReport); dataOut.println("Duty Assignments:\n\n"); dataOut.println(best.toString()); } catch (IOException e) { ErrorChecker.printExceptionToLog(e); } finally { dataOut.close(); } }
From source file:com.vmware.identity.samlservice.Shared.java
/** * Send HTTP response/*from ww w. j av a2 s . co m*/ * @param response * @param contentType * @param str * @throws IOException */ public static void sendResponse(HttpServletResponse response, String contentType, String str) throws IOException { response.setContentType(contentType); PrintWriter out = response.getWriter(); out.println(str); out.close(); }
From source file:cltestgrid.Upload2.java
/** Formats a Map so that it can be read by Lisp readers as an association list. *//*from w w w . j a v a 2s . co m*/ private static String asAssocList(Map<String, String> map) { StringWriter buf = new StringWriter(); PrintWriter out = new PrintWriter(buf); out.println("("); for (String key : map.keySet()) { String val = map.get(key); out.println(" (\"" + key + "\" . \"" + val + "\")"); } out.println(")"); return buf.toString(); }
From source file:com.amazonaws.eclipse.core.diagnostic.utils.AwsPortalFeedbackFormUtils.java
/** * Serialize the specified error report data into "x-www-form-urlencoded" * format. This method also appends additional parameters that are * implicitly required by the Amazon HTMLForms system (including * authenticity_token).// w ww. j ava 2s .co m */ private static String generateFormPostContent(final ErrorReportDataModel reportData, final String authentityToken) { StringBuilder content = new StringBuilder(); // These are the additional fields required by the POST API content.append(AUTHENTICITY_TOKEN).append("=").append(SdkHttpUtils.urlEncode(authentityToken, false)); content.append("&_method=put"); // These are the "real" data fields /* ============= User email ============= */ content.append("&"); content.append(FORM_FIELD_PREFIX).append(EMAIL).append("="); content.append(SdkHttpUtils.urlEncode(reportData.getUserEmail(), false)); /* ============= User description of the error ============= */ content.append("&"); content.append(FORM_FIELD_PREFIX).append(USER_DESCRIPTION).append("="); content.append(SdkHttpUtils.urlEncode(reportData.getUserDescription(), false)); /* ============= Error stack trace ============= */ content.append("&"); content.append(FORM_FIELD_PREFIX).append(ERROR_STACKTRACE).append("="); content.append(SdkHttpUtils.urlEncode(getStackTraceFromThrowable(reportData.getBug()), false)); /* ============= Error status message ============= */ content.append("&"); content.append(FORM_FIELD_PREFIX).append(ERROR_STATUS_MESSAGE).append("="); content.append(SdkHttpUtils.urlEncode(reportData.getStatusMessage(), false)); PlatformEnvironmentDataModel env = reportData.getPlatformEnv(); /* ============= Platform environment ============= */ content.append("&"); content.append(FORM_FIELD_PREFIX).append(ECLIPSE_PLATFORM_ENV).append("="); if (env != null) { StringWriter eclipsePlatformEnv = new StringWriter(); PrintWriter pw = new PrintWriter(eclipsePlatformEnv); pw.print("Eclipse platform version : "); pw.println(env.getEclipsePlatformVersion()); pw.print("OS name : "); pw.println(env.getOsName()); pw.print("OS version : "); pw.println(env.getOsVersion()); pw.print("OS architecture : "); pw.println(env.getOsArch()); pw.print("JVM name : "); pw.println(env.getJavaVmName()); pw.print("JVM version : "); pw.println(env.getJavaVmVersion()); pw.print("Java lang version : "); pw.println(env.getJavaVersion()); pw.println(); pw.println(); content.append(SdkHttpUtils.urlEncode(eclipsePlatformEnv.toString(), false)); } /* ============= Installed Plug-ins ============= */ content.append("&"); content.append(FORM_FIELD_PREFIX).append(INSTALLED_PLUGINS).append("="); if (env != null) { StringWriter installedPlugins = new StringWriter(); PrintWriter pw = new PrintWriter(installedPlugins); for (Bundle bundle : env.getInstalledBundles()) { pw.println(bundle.toString()); } content.append(SdkHttpUtils.urlEncode(installedPlugins.toString(), false)); } return content.toString(); }
From source file:com.espertech.esper.view.ViewSupport.java
private static void printObjectArray(String prefix, PrintWriter writer, Object[] objects) { int count = 0; for (Object object : objects) { String objectToString = (object == null) ? "null" : object.toString(); writer.println(prefix + " #" + count + " = " + objectToString); }//from w w w .j a va 2 s . co m }
From source file:gov.nih.nci.evs.testUtil.BaseUITestGenerator.java
public static void printLicenseStatement(PrintWriter out) { out.println("/**"); out.println(" * <!-- LICENSE_TEXT_START -->"); out.println(" * Copyright 2015 NGIS. This software was developed in conjunction"); out.println(" * with the National Cancer Institute, and so to the extent government"); out.println(" * employees are co-authors, any rights in such works shall be subject"); out.println(" * to Title 17 of the United States Code, section 105."); out.println(" * Redistribution and use in source and binary forms, with or without"); out.println(" * modification, are permitted provided that the following conditions"); out.println(" * are met:");//from ww w .j av a 2 s . c om out.println(" * 1. Redistributions of source code must retain the above copyright"); out.println(" * notice, this list of conditions and the disclaimer of Article 3,"); out.println(" * below. Redistributions in binary form must reproduce the above"); out.println(" * copyright notice, this list of conditions and the following"); out.println(" * disclaimer in the documentation and/or other materials provided"); out.println(" * with the distribution."); out.println(" * 2. The end-user documentation included with the redistribution,"); out.println(" * if any, must include the following acknowledgment:"); out.println(" * \"This product includes software developed by NGIT and the National"); out.println(" * Cancer Institute.\" If no such end-user documentation is to be"); out.println(" * included, this acknowledgment shall appear in the software itself,"); out.println(" * wherever such third-party acknowledgments normally appear."); out.println(" * 3. The names \"The National Cancer Institute\", \"NCI\" and \"NGIT\" must"); out.println(" * not be used to endorse or promote products derived from this software."); out.println(" * 4. This license does not authorize the incorporation of this software"); out.println(" * into any third party proprietary programs. This license does not"); out.println(" * authorize the recipient to use any trademarks owned by either NCI"); out.println(" * or NGIT"); out.println(" * 5. THIS SOFTWARE IS PROVIDED \"AS IS,\" AND ANY EXPRESSED OR IMPLIED"); out.println(" * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES"); out.println(" * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE"); out.println(" * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE,"); out.println(" * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT,"); out.println(" * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,"); out.println(" * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;"); out.println(" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER"); out.println(" * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT"); out.println(" * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN"); out.println(" * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE"); out.println(" * POSSIBILITY OF SUCH DAMAGE."); out.println(" * <!-- LICENSE_TEXT_END -->"); out.println(" */"); out.println(""); out.println("/**"); out.println(" * @author EVS Team"); out.println(" * @version 1.0"); out.println(" *"); out.println(" * Modification history Initial implementation kim.ong@ngc.com"); out.println(" *"); out.println(" */"); }
From source file:gov.nih.nci.evs.testUtil.BaseUITestGenerator.java
public static void printClassDefinition(PrintWriter out, String className) { out.println("public class " + className + " {"); out.println(" private WebDriver driver;"); out.println(" private String baseUrl;"); out.println(" private boolean acceptNextAlert = true;"); out.println(" private StringBuffer verificationErrors = new StringBuffer();"); out.println(""); out.println(" private LexBIGService lbSvc = null;"); out.println(" private String serviceUrl = null;"); out.println(" private SimpleSearchUtils simpleSearchUtils = null;"); out.println(" private MappingSearchUtils mappingSearchUtils = null;"); out.println(" private ValueSetSearchUtils valueSetSearchUtils = null;"); out.println(" private ConceptDetails conceptDetails = null;"); out.println(" private SearchUtils searchUtils = null;"); out.println(""); out.println(" private String scheme = null;"); out.println(" private String version = null;"); out.println(" private String matchText = null;"); out.println(" private String target = null;"); out.println(" private int searchOption = 2;"); out.println(" private String algorithm = null;"); out.println(" private String propertyName = null;"); out.println(" private ResolvedConceptReferencesIterator rcr_iterator = null;"); out.println(" private ResolvedConceptReference rcref = null;"); out.println(" private int search_direction = gov.nih.nci.evs.browser.common.Constants.SEARCH_SOURCE;"); out.println(" private int maxToReturn = -1;"); out.println(" private String source = null;"); out.println(" private String[] associationsToNavigate = null;"); out.println(" private String[] association_qualifier_names = null;"); out.println(" private String[] association_qualifier_values = null;"); out.println(" private boolean excludeDesignation = true;"); out.println(" private boolean ranking = true;"); out.println(""); }
From source file:Main.java
/** * Display info about a thread group and its threads and groups *///from w w w . j a v a 2 s . c o m private static void printGroupInfo(PrintWriter out, ThreadGroup g, String indent) { if (g == null) { return; } int num_threads = g.activeCount(); int num_groups = g.activeGroupCount(); Thread[] threads = new Thread[num_threads]; ThreadGroup[] groups = new ThreadGroup[num_groups]; g.enumerate(threads, false); g.enumerate(groups, false); out.println(indent + "Thread Group: " + g.getName() + " Max Priority: " + g.getMaxPriority() + (g.isDaemon() ? " Daemon" : "")); for (int i = 0; i < num_threads; i++) { printThreadInfo(out, threads[i], indent + " "); } for (int i = 0; i < num_groups; i++) { printGroupInfo(out, groups[i], indent + " "); } }
From source file:gov.nih.nci.evs.testUtil.BaseUITestGenerator.java
public static void printAfter(PrintWriter out) { out.println(" public static int getHTTPResponseCode(String url) {"); out.println(" try {"); out.println(" URL u = new URL(url);"); out.println(" HttpURLConnection huc = (HttpURLConnection)u.openConnection();"); out.println(" huc.setRequestMethod(\"GET\");"); out.println(" huc.connect() ;"); out.println(" int code = huc.getResponseCode();"); out.println(" return code;"); out.println(" } catch (Exception ex) {"); out.println(" ex.printStackTrace();"); out.println(" }"); out.println(" return -1;"); out.println(" }"); out.println("\n"); out.println(" @After"); out.println(" public void tearDown() throws Exception {"); out.println(" if (driver != null) driver.quit();"); out.println(" String verificationErrorString = verificationErrors.toString();"); out.println(" if (!\"\".equals(verificationErrorString)) {"); out.println(" fail(verificationErrorString);"); out.println(" }"); out.println(" }"); out.println(""); out.println(" private boolean isElementPresent(By by) {"); out.println(" try {"); out.println(" driver.findElement(by);"); out.println(" return true;"); out.println(" } catch (NoSuchElementException e) {"); out.println(" return false;"); out.println(" }"); out.println(" }"); out.println(""); out.println(" private boolean isAlertPresent() {"); out.println(" try {"); out.println(" driver.switchTo().alert();"); out.println(" return true;"); out.println(" } catch (NoAlertPresentException e) {"); out.println(" return false;"); out.println(" }"); out.println(" }"); out.println(""); out.println(" private String closeAlertAndGetItsText() {"); out.println(" try {"); out.println(" Alert alert = driver.switchTo().alert();"); out.println(" String alertText = alert.getText();"); out.println(" if (acceptNextAlert) {"); out.println(" alert.accept();"); out.println(" } else {"); out.println(" alert.dismiss();"); out.println(" }"); out.println(" return alertText;"); out.println(" } finally {"); out.println(" acceptNextAlert = true;"); out.println(" }"); out.println(" }"); out.println("}"); }
From source file:org.glowroot.tests.WebDriverSetup.java
private static CentralModule createCentralModule(int uiPort, int grpcPort) throws Exception { File centralDir = new File("target"); File propsFile = new File(centralDir, "glowroot-central.properties"); PrintWriter props = new PrintWriter(propsFile); props.println("cassandra.keyspace=glowroot_unit_tests"); byte[] bytes = new byte[16]; new SecureRandom().nextBytes(bytes); props.println("cassandra.symmetricEncryptionKey=" + BaseEncoding.base16().lowerCase().encode(bytes)); props.println("grpc.httpPort=" + grpcPort); props.println("ui.port=" + uiPort); props.close();/*from w w w .j a va2 s.c om*/ String prior = System.getProperty("glowroot.log.dir"); try { System.setProperty("glowroot.log.dir", "target"); return CentralModule.create(centralDir); } finally { if (prior == null) { System.clearProperty("glowroot.log.dir"); } else { System.setProperty("glowroot.log.dir", prior); } } }