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:net.poemerchant.ui.ScraperSwingWorker.java
@Override public Void doInBackground() throws Exception { // all logger message will also go to our printStream logger.addHandler(new StreamHandler(printStream, new Formatter() { @Override//from w ww .j av a 2 s .c o m public String format(LogRecord record) { // System.out.println("intercept: " + record.getMessage()); return record.getMessage() + System.lineSeparator(); } }) { @Override public synchronized void publish(LogRecord record) { super.publish(record); flush(); } }); ShopIndexScraper scraper = new ShopIndexScraper(shopSubForumUrl); logger.info("Scrapping shops subform index: " + shopSubForumUrl); List<String> shopUrls = null; try { shopUrls = scraper.scrape(); } catch (PoEMerchantException e) { logger.severe("Error: " + e.getMessage() + ". Try again."); return null; } // shopUrls = new ArrayList(); // shopUrls.add(this.getClass().getResource("/1148541.htm").getFile()); logger.info("Sucessfully scraped subform, number of shops: " + shopUrls.size()); for (String url : shopUrls) { logger.info("Scrapping shop: " + url); try { scrapeAndSaveShop(configuration.getIndex(), configuration.getType(), url); } catch (Exception e) { logger.severe("error caught for " + url + ". err msg: " + e.getMessage()); } } logger.info(String.format("Sucessfully scraped %d shops.", shopUrls.size())); return null; }
From source file:net.resheim.eclipse.timekeeper.ui.views.ExportToClipboard.java
public void copyWeekAsHTML(LocalDate firstDayOfWeek) { provider = new AbstractContentProvider() { @Override// ww w . j a v a 2 s .co m public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { this.setFirstDayOfWeek(firstDayOfWeek); filter(); } @Override public void dispose() { // ignore } }; provider.inputChanged(null, null, null); StringBuilder sb = new StringBuilder(); sb.append("<table width=\"100%\" style=\"border: 1px solid #aaa; border-collapse: collapse; \">"); sb.append(System.lineSeparator()); sb.append("<tr style=\"background: #dedede; border-bottom: 1px solid #aaa\">"); sb.append("<th>"); sb.append("Week "); sb.append(firstDayOfWeek.format(weekFormat)); sb.append("</th>"); String[] headings = Activator.getDefault().getHeadings(firstDayOfWeek); for (String heading : headings) { sb.append("<th width=\"50em\" style=\"text-align: center; border-left: 1px solid #aaa\">"); sb.append(heading); sb.append("</th>"); } sb.append("</th>"); sb.append(System.lineSeparator()); Object[] elements = provider.getElements(null); for (Object object : elements) { append(firstDayOfWeek, sb, object); } sb.append("</table>"); HTMLTransfer textTransfer = HTMLTransfer.getInstance(); TextTransfer tt = TextTransfer.getInstance(); Clipboard clipboard = new Clipboard(Display.getCurrent()); clipboard.setContents(new String[] { sb.toString(), sb.toString() }, new Transfer[] { textTransfer, tt }); clipboard.dispose(); }
From source file:com.github.robozonky.app.runtime.LivenessCheck.java
@Override protected String getLatestSource() { logger.trace("Running."); // need to send parsed version, since the object itself changes every time due to currentApiTime field return Try.withResources(() -> UrlUtil.open(new URL(url))).of(s -> { final String source = IOUtils.readLines(s, Defaults.CHARSET).stream() .collect(Collectors.joining(System.lineSeparator())); logger.trace("API info coming from Zonky: {}.", source); return read(source); }).getOrElseGet(ex -> {/*from w w w . ja va 2 s . co m*/ // don't propagate this exception as it is likely to happen and the calling code would WARN about it logger.debug("Zonky servers are likely unavailable.", ex); return null; // will fail during transform() }); }
From source file:com.cloudbees.jenkins.support.filter.FilteredOutputStreamTest.java
@Issue("JENKINS-21670") @Test/*from w w w. jav a 2 s .c o m*/ public void shouldModifyStream() throws IOException { final int nrLines = FilteredConstants.DEFAULT_DECODER_CAPACITY; String inputContents = IntStream.range(0, nrLines).mapToObj(i -> "Line " + i) .collect(joining(System.lineSeparator())); CharSequenceInputStream input = new CharSequenceInputStream(inputContents, UTF_8); ContentFilter filter = s -> s.replace("Line", "Network"); FilteredOutputStream output = new FilteredOutputStream(testOutput, filter); IOUtils.copy(input, output); output.flush(); String outputContents = new String(testOutput.toByteArray(), UTF_8); assertThat(outputContents).isNotEmpty(); String[] lines = FilteredConstants.EOL.split(outputContents); assertThat(lines).allMatch(line -> !line.contains("Line") && line.startsWith("Network")).hasSize(nrLines); }
From source file:org.assertj.maven.generator.AssertionsGeneratorReport.java
public String getReportContent() { StringBuilder reportBuilder = new StringBuilder(System.lineSeparator()); reportBuilder.append(System.lineSeparator()); reportBuilder.append("====================================\n"); reportBuilder.append("AssertJ assertions generation report\n"); reportBuilder.append("====================================\n"); buildGeneratorParametersReport(reportBuilder); reportBuilder.append(System.lineSeparator()); reportBuilder.append(SECTION_START).append("Generator results").append(SECTION_END); if (generationError()) { buildGeneratorReportError(reportBuilder); } else if (nothingGenerated()) { buildGeneratorReportWhenNothingWasGenerated(reportBuilder); } else {//from www . ja va 2 s .co m buildGeneratorReportSuccess(reportBuilder); } return reportBuilder.toString(); }
From source file:org.smigo.config.DevelopmentConfiguration.java
@Bean public JavaMailSenderImpl javaMailSender() { return new JavaMailSenderImpl() { @Override//w w w . j av a 2 s . c o m public String getDefaultEncoding() { return "UTF-8"; } @Override public void send(SimpleMailMessage simpleMessage) throws MailException { try { //Thread.sleep(2000); String text = simpleMessage.getText(); String subject = simpleMessage.getSubject(); FileUtils.writeStringToFile(MAIL_FILE, text, Charset.defaultCharset()); FileUtils.writeStringToFile(MAIL_FILE_TXT, subject + System.lineSeparator() + text, Charset.defaultCharset()); } catch (Exception e) { throw new MailSendException("Error sending email to " + simpleMessage.getFrom(), e); } } @Override public void send(MimeMessage mimeMessage) throws MailException { try { final String s = IOUtils.toString(mimeMessage.getInputStream()); FileUtils.writeStringToFile(MAIL_FILE, s, Charset.defaultCharset()); } catch (IOException | MessagingException e) { throw new MailSendException("Error sending email: " + mimeMessage.toString(), e); } } @Override public void send(SimpleMailMessage[] simpleMessages) throws MailException { throw new MailPreparationException("Method not supported"); } }; }
From source file:com.datasayer.meerkat.TestMeerkatMain.java
private String randomString(final int length) { Random r = new Random(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { char c = (char) (r.nextInt((int) (Character.MAX_VALUE))); sb.append(c);//w ww. jav a 2 s .c o m } sb.append(System.lineSeparator()); return sb.toString(); }
From source file:ch.oakmountain.tpa.web.TpaWebPersistor.java
private static void writeGraph(File file, IGraph graph) throws IOException { String header = "source,target,category,linkDescription,sourceGroup,targetGroup,sourceGroupDescription,targetGroupDescription" + System.lineSeparator(); FileUtils.writeStringToFile(file, header); TpaWebPersistor graphweb = new TpaWebPersistor(file); graph.writeLines(graphweb);//from w ww . ja v a2 s. co m }
From source file:org.bonitasoft.web.designer.model.JacksonObjectMapperTest.java
@Test public void should_format_json_when_using_pretty_print_on_json() throws Exception { assertThat(objectMapper.prettyPrint("{\"foo\":\"bar\"}")) .isEqualTo("{" + System.lineSeparator() + " \"foo\" : \"bar\"" + System.lineSeparator() + "}"); }
From source file:com.evrythng.thng.resource.model.exception.ErrorMessage.java
@JsonIgnore public String errorsAsString() { return StringUtils.join(errors, "," + System.lineSeparator()); }