List of usage examples for java.lang System lineSeparator
String lineSeparator
To view the source code for java.lang System lineSeparator.
Click Source Link
From source file:org.nuxeo.client.internals.spi.NuxeoClientException.java
public String getRemoteStackTrace() { Field[] fields = this.getClass().getDeclaredFields(); StringBuilder result = new StringBuilder(); for (Field field : fields) { try {//from w w w . jav a2 s. c o m if (Modifier.isPrivate(field.getModifiers()) || field.get(this) == null) { continue; } result.append(" "); result.append(field.getName()); result.append(": "); result.append(field.get(this)); } catch (IllegalAccessException ex) { System.out.println(ex); } result.append(System.lineSeparator()); } return result.toString(); }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testVersionPrint() throws Exception { exit.checkAssertionAfterwards(new Assertion() { @Override/* w ww .j a va 2 s.c o m*/ public void checkAssertion() { assertEquals("Checkstyle version: null" + System.lineSeparator(), systemOut.getLog()); assertEquals("", systemErr.getLog()); } }); Main.main("-v"); }
From source file:org.apache.nifi.toolkit.tls.commandLine.BaseCommandLine.java
public BaseCommandLine(String header) { this.header = System.lineSeparator() + header + System.lineSeparator() + System.lineSeparator(); this.options = new Options(); if (shouldAddDaysArg()) { addOptionWithArg("d", DAYS_ARG, "Number of days issued certificate should be valid for.", TlsConfig.DEFAULT_DAYS); }/*from w w w . j a v a 2 s . c om*/ addOptionWithArg("T", KEY_STORE_TYPE_ARG, "The type of keyStores to generate.", getKeyStoreTypeDefault()); options.addOption("h", HELP_ARG, false, "Print help and exit."); addOptionWithArg("c", CERTIFICATE_AUTHORITY_HOSTNAME_ARG, "Hostname of NiFi Certificate Authority", TlsConfig.DEFAULT_HOSTNAME); addOptionWithArg("a", KEY_ALGORITHM_ARG, "Algorithm to use for generated keys.", TlsConfig.DEFAULT_KEY_PAIR_ALGORITHM); addOptionWithArg("k", KEY_SIZE_ARG, "Number of bits for generated keys.", TlsConfig.DEFAULT_KEY_SIZE); if (shouldAddSigningAlgorithmArg()) { addOptionWithArg("s", SIGNING_ALGORITHM_ARG, "Algorithm to use for signing certificates.", TlsConfig.DEFAULT_SIGNING_ALGORITHM); } addOptionNoArg("g", DIFFERENT_KEY_AND_KEYSTORE_PASSWORDS_ARG, "Use different generated password for the key and the keyStore."); }
From source file:org.smigo.log.LogController.java
@RequestMapping(value = { "/rest/note" }, method = RequestMethod.POST) @ResponseBody/*from w w w. j a v a 2s .c o m*/ public void adminNote(@RequestBody AdminNote note, HttpServletRequest request, HttpServletResponse response) { String msg = note.getMessage() + System.lineSeparator() + logHandler.getRequestDump(request, response, System.lineSeparator()); mailHandler.sendAdminNotification("frontend note", msg); }
From source file:adams.data.image.ImageMetaDataHelper.java
/** * Reads the meta-data from the file (using Sanselan). * /*w w w .j a v a 2 s.co m*/ * @param file the file to read the meta-data from * @return the meta-data * @throws Exception if failed to read meta-data */ public static SpreadSheet sanselan(File file) throws Exception { SpreadSheet sheet; Row row; org.apache.sanselan.common.IImageMetadata meta; String[] parts; String key; String value; org.apache.sanselan.ImageInfo info; String infoStr; String[] lines; HashSet<String> keys; sheet = new DefaultSpreadSheet(); // header row = sheet.getHeaderRow(); row.addCell("K").setContent("Key"); row.addCell("V").setContent("Value"); keys = new HashSet<String>(); // meta-data meta = Sanselan.getMetadata(file.getAbsoluteFile()); if (meta != null) { for (Object item : meta.getItems()) { key = null; value = null; if (item instanceof ImageMetadata.Item) { key = ((ImageMetadata.Item) item).getKeyword().trim(); value = ((ImageMetadata.Item) item).getText().trim(); } else { parts = item.toString().split(": "); if (parts.length == 2) { key = parts[0].trim(); value = parts[1].trim(); } } if (key != null) { if (!keys.contains(key)) { keys.add(key); row = sheet.addRow(); row.addCell("K").setContent(key); row.addCell("V").setContent(fixDateTime(Utils.unquote(value))); } } } } // image info info = Sanselan.getImageInfo(file.getAbsoluteFile()); if (info != null) { infoStr = info.toString(); lines = infoStr.split(System.lineSeparator()); for (String line : lines) { parts = line.split(": "); if (parts.length == 2) { key = parts[0].trim(); value = parts[1].trim(); if (!keys.contains(key)) { row = sheet.addRow(); row.addCell("K").setContent(key); row.addCell("V").setContent(Utils.unquote(value)); keys.add(key); } } } } return sheet; }
From source file:org.apache.brooklyn.core.config.external.vault.VaultExternalConfigSupplier.java
public VaultExternalConfigSupplier(ManagementContext managementContext, String name, Map<String, String> config) { super(managementContext, name); this.config = config; this.name = name; httpClient = HttpTool.httpClientBuilder().build(); gson = new GsonBuilder().create(); List<String> errors = Lists.newArrayListWithCapacity(2); endpoint = config.get("endpoint"); if (Strings.isBlank(endpoint)) errors.add("missing configuration 'endpoint'"); path = config.get("path"); if (Strings.isBlank(path)) errors.add("missing configuration 'path'"); if (!errors.isEmpty()) { String message = String.format("Problem configuration Vault external config supplier '%s': %s", name, Joiner.on(System.lineSeparator()).join(errors)); throw new IllegalArgumentException(message); }/*from w ww .j a v a 2 s . c om*/ token = initAndLogIn(config); headersWithToken = ImmutableMap.<String, String>builder().putAll(MINIMAL_HEADERS) .put("X-Vault-Token", token).build(); }
From source file:org.wso2.carbon.esb.passthru.transport.test.ESBJAVA4631PreserveHTTPHeadersTest.java
@Test(groups = "wso2.esb", description = "Preserve Content-Type header test", enabled = true) public void testPreserveContentTypeHeader() throws Exception { wireServer.start();/*ww w.ja v a2 s . c o m*/ DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(getApiInvocationURL("ContentTypePreserveAPI")); StringEntity postingString = new StringEntity("{\"sampleJson\" : \"sampleValue\"}"); httppost.setEntity(postingString); httppost.setHeader("Content-type", "application/json"); try { httpclient.execute(httppost); } finally { httpclient.clearRequestInterceptors(); } String wireResponse = wireServer.getCapturedMessage(); String[] wireResponseLines = wireResponse.split(System.lineSeparator()); boolean isContentTypePresent = false; for (String line : wireResponseLines) { if (line.contains("Content-Type")) { isContentTypePresent = true; //charset encoding is appended to content-type header even preserve the content-type header as it is //This checks charset encoding is appended or not Assert.assertFalse(line.contains(";"), "Content-Type header was modified - " + line); } } //coming to this line means content type header is in expected state, hence passing the test Assert.assertTrue(isContentTypePresent, "Content-Type header is not present in the ESB request"); }
From source file:android.databinding.tool.processing.ScopedException.java
private String createEncodedMessage() { ScopedErrorReport scopedError = getScopedErrorReport(); StringBuilder sb = new StringBuilder(); sb.append(ERROR_LOG_PREFIX).append(MSG_KEY).append(super.getMessage()).append("\n").append(FILE_KEY) .append(scopedError.getFilePath()).append("\n"); if (scopedError.getLocations() != null) { for (Location location : scopedError.getLocations()) { sb.append(LOCATION_KEY).append(location.toUserReadableString()).append("\n"); }/*from www.ja va2s.c o m*/ } sb.append(ERROR_LOG_SUFFIX); return StringUtils.join(StringUtils.split(sb.toString(), System.lineSeparator()), " "); }
From source file:com.glluch.profilesparser.Writer.java
/** * Prepare the terms for Solr's xml./*from w w w . j a v a 2 s . c om*/ * @param field_name The name of the Solr's field. * @param terms A hash map terms -> counts to be transform as xml. * @return An xml string which is the part representing the terms. */ protected String terms2xml(String field_name, HashMap<String, Double> terms) { String text = ""; Set pterms = terms.keySet(); for (Object t0 : pterms) { String t = (String) t0; text += "<field name=\"" + field_name + "\" " + " boost=\"" + term_boost * terms.get(t) + "\"" + ">" + t + "</field>" + System.lineSeparator(); } return text; }
From source file:org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsBlkioResourceHandlerImpl.java
private void checkDiskScheduler() { String data;/*from w ww . java 2s . c o m*/ // read /proc/partitions and check to make sure that sd* and hd* // are using the CFQ scheduler. If they aren't print a warning try { byte[] contents = Files.readAllBytes(Paths.get(PARTITIONS_FILE)); data = new String(contents, "UTF-8").trim(); } catch (IOException e) { String msg = "Couldn't read " + PARTITIONS_FILE + "; can't determine disk scheduler type"; LOG.warn(msg, e); return; } String[] lines = data.split(System.lineSeparator()); if (lines.length > 0) { for (String line : lines) { String[] columns = line.split("\\s+"); if (columns.length > 4) { String partition = columns[4]; // check some known partitions to make sure the disk scheduler // is cfq - not meant to be comprehensive, more a sanity check if (partition.startsWith("sd") || partition.startsWith("hd") || partition.startsWith("vd") || partition.startsWith("xvd")) { String schedulerPath = "/sys/block/" + partition + "/queue/scheduler"; File schedulerFile = new File(schedulerPath); if (schedulerFile.exists()) { try { byte[] contents = Files.readAllBytes(Paths.get(schedulerPath)); String schedulerString = new String(contents, "UTF-8").trim(); if (!schedulerString.contains("[cfq]")) { LOG.warn("Device " + partition + " does not use the CFQ" + " scheduler; disk isolation using " + "CGroups will not work on this partition."); } } catch (IOException ie) { LOG.warn("Unable to determine disk scheduler type for partition " + partition, ie); } } } } } } }