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:de.fosd.jdime.Main.java
/** * Perform a merge operation on the input files or directories. * * @param args// w ww . j a va2 s.c om * command line arguments */ public static void run(String[] args) { MergeContext context = new MergeContext(); if (!parseCommandLineArgs(context, args)) { return; } List<FileArtifact> inputFiles = context.getInputFiles(); if (context.isInspect()) { inspectElement(inputFiles.get(0), context.getInspectArtifact(), context.getInspectionScope()); return; } if (context.getDumpMode() != DumpMode.NONE) { inputFiles.forEach(artifact -> dump(artifact, context.getDumpMode())); return; } try { merge(context); output(context); } finally { outputStatistics(context); } if (LOG.isLoggable(Level.FINE)) { Map<MergeScenario<?>, Throwable> crashes = context.getCrashes(); if (crashes.isEmpty()) { LOG.fine("No crashes occurred while merging."); } else { String ls = System.lineSeparator(); StringBuilder sb = new StringBuilder(); sb.append(String.format("%d crashes occurred while merging:%n", crashes.size())); for (Map.Entry<MergeScenario<?>, Throwable> entry : crashes.entrySet()) { sb.append("* ").append(entry.getValue().toString()).append(ls); sb.append(" ").append(entry.getKey().toString().replace(" ", ls + " ")).append(ls); } LOG.fine(sb.toString()); } } }
From source file:me.mayo.telnetkek.MainPanel.java
private void writeToConsoleImmediately(final ConsoleMessage message, final boolean isTelnetError) { SwingUtilities.invokeLater(() -> { if (isTelnetError && chkIgnoreErrors.isSelected()) { return; }//from w w w. j a v a 2s . co m final StyledDocument styledDocument = mainOutput.getStyledDocument(); int startLength = styledDocument.getLength(); try { styledDocument.insertString(styledDocument.getLength(), message.getMessage() + System.lineSeparator(), StyleContext.getDefaultStyleContext().addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, message.getColor())); } catch (BadLocationException ex) { throw new RuntimeException(ex); } if (MainPanel.this.chkAutoScroll.isSelected() && MainPanel.this.mainOutput.getSelectedText() == null) { final JScrollBar vScroll = mainOutputScoll.getVerticalScrollBar(); if (!vScroll.getValueIsAdjusting()) { if (vScroll.getValue() + vScroll.getModel().getExtent() >= (vScroll.getMaximum() - 50)) { MainPanel.this.mainOutput.setCaretPosition(startLength); final Timer timer = new Timer(10, (ActionEvent ae) -> { vScroll.setValue(vScroll.getMaximum()); }); timer.setRepeats(false); timer.start(); } } } }); }
From source file:com.megahardcore.config.messages.MessageConfig.java
/** * Set the header of the file before writing to it with bukkit yaml implementation * * @param file file to write the header to *//*from ww w .j a va 2 s .c o m*/ private void setHeader(File file) { try { //Write header to a new file ByteArrayOutputStream memStream = new ByteArrayOutputStream(); OutputStreamWriter memWriter = new OutputStreamWriter(memStream, Charset.forName("UTF-8").newEncoder()); String[] header = { "Messages sent by MegaHardCore", "Messages are only sent for modules that are activated", "Modes (has to match exactly, ignores case)", "Disabled: Message won't be sent even if feature that would sent the message is active", "One_Time: Will be sent to every player only once", "Notification: Gets sent every time with a timeout to prevent spamming chat", "Tutorial: Sent a limited number of times and not displayed after 3 times", "Broadcast: Shown to whole server. Only few messages make sense to be broadcasted", "Variables:", "$ALLCAPS is a variable and will be filled in for some messages", "$PLAYER: Affected player", "$PLAYERS: If multiple players are affected", "$DEATH_MSG: Death message if someone dies", "$ITEMS: a player lost" }; StringBuilder sb = new StringBuilder(); sb.append(StringUtils.repeat("#", 100)); sb.append(System.lineSeparator()); for (String line : header) { sb.append('#'); sb.append(StringUtils.repeat(" ", 100 / 2 - line.length() / 2 - 1)); sb.append(line); sb.append(StringUtils.repeat(" ", 100 / 2 - line.length() / 2 - 1 - line.length() % 2)); sb.append('#'); sb.append(String.format(System.lineSeparator())); } sb.append(StringUtils.repeat("#", 100)); sb.append(String.format(System.lineSeparator())); //String.format: %n as platform independent line seperator memWriter.write(sb.toString()); memWriter.close(); IoHelper.writeHeader(file, memStream); } catch (IOException e) { e.printStackTrace(); } }
From source file:ninja.utils.CookieEncryption.java
private String getHelperLogMessage() { StringBuilder sb = new StringBuilder(); sb.append("Invalid key provided. Check if application secret is properly set.") .append(System.lineSeparator()); sb.append("You can remove '").append(NinjaConstant.applicationSecret) .append("' key in configuration file "); sb.append("and restart application. Ninja will generate new key for you."); return sb.toString(); }
From source file:org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.TrafficControlBandwidthHandlerImpl.java
/** * Bootstrapping 'outbound-bandwidth' resource handler - mounts net_cls * controller and bootstraps a traffic control bandwidth shaping hierarchy * @param configuration yarn configuration in use * @return (potentially empty) list of privileged operations to execute. * @throws ResourceHandlerException/*from ww w .j av a 2 s . c o m*/ */ @Override public List<PrivilegedOperation> bootstrap(Configuration configuration) throws ResourceHandlerException { conf = configuration; //We'll do this inline for the time being - since this is a one time //operation. At some point, LCE code can be refactored to batch mount //operations across multiple controllers - cpu, net_cls, blkio etc cGroupsHandler.mountCGroupController(CGroupsHandler.CGroupController.NET_CLS); device = conf.get(YarnConfiguration.NM_NETWORK_RESOURCE_INTERFACE, YarnConfiguration.DEFAULT_NM_NETWORK_RESOURCE_INTERFACE); strictMode = configuration.getBoolean(YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_STRICT_RESOURCE_USAGE, YarnConfiguration.DEFAULT_NM_LINUX_CONTAINER_CGROUPS_STRICT_RESOURCE_USAGE); rootBandwidthMbit = conf.getInt(YarnConfiguration.NM_NETWORK_RESOURCE_OUTBOUND_BANDWIDTH_MBIT, YarnConfiguration.DEFAULT_NM_NETWORK_RESOURCE_OUTBOUND_BANDWIDTH_MBIT); yarnBandwidthMbit = conf.getInt(YarnConfiguration.NM_NETWORK_RESOURCE_OUTBOUND_BANDWIDTH_YARN_MBIT, rootBandwidthMbit); containerBandwidthMbit = (int) Math.ceil((double) yarnBandwidthMbit / MAX_CONTAINER_COUNT); StringBuffer logLine = new StringBuffer("strict mode is set to :").append(strictMode) .append(System.lineSeparator()); if (strictMode) { logLine.append("container bandwidth will be capped to soft limit.").append(System.lineSeparator()); } else { logLine.append("containers will be allowed to use spare YARN bandwidth.") .append(System.lineSeparator()); } logLine.append("containerBandwidthMbit soft limit (in mbit/sec) is set to : ") .append(containerBandwidthMbit); LOG.info(logLine); trafficController.bootstrap(device, rootBandwidthMbit, yarnBandwidthMbit); return null; }
From source file:de.vandermeer.asciitable.AT_Renderer.java
/** * Renders an {@link AsciiTable}./*from w w w. j a v a 2 s . co m*/ * @param rows table rows to render, cannot be null * @param colNumbers number of columns in the table * @param ctx context of the original table with relevant settings, cannot be null * @param width maximum line width, excluding any extra padding * @return a single string with the rendered table * @throws {@link NullPointerException} if rows or context where null */ default String render(LinkedList<AT_Row> rows, int colNumbers, AT_Context ctx, int width) { Validate.notNull(rows); Validate.notNull(ctx); Collection<StrBuilder> coll = this.renderAsCollection(rows, colNumbers, ctx, width); String fileSeparator = this.getLineSeparator(); if (fileSeparator == null) { fileSeparator = ctx.getLineSeparator(); } if (fileSeparator == null) { fileSeparator = System.lineSeparator(); } return new StrBuilder().appendWithSeparators(coll, fileSeparator).build(); }
From source file:glluch.com.ontotaxoseeker.TaxoPath.java
/** * Creates a String ready for print.//from w w w.j a va 2 s. c o m * @param termsPaths The list of term and its counts. * @return An String with a line per path and its ocurrences. */ public String prettyPrintPaths(PathsCount termsPaths) { //debug("prettyPrintPaths"); String s = ""; Iterator ite = termsPaths.iterator(); while (ite.hasNext()) { Path p = (Path) ite.next(); s += p.prettyPrint() + " -> " + termsPaths.get(p) + System.lineSeparator(); } return s; }
From source file:org.smigo.user.UserHandler.java
public void updateUser(int userId, User update) { final User current = userDao.getUserById(userId); log.info("User updated account. Current:" + current + " Update:" + update); mailHandler.sendAdminNotification("user updated account", "Current:" + current + System.lineSeparator() + "Update:" + update); current.setAbout(update.getAbout()); current.setDisplayName(update.getDisplayName()); current.setEmail(update.getEmail()); current.setLocale(update.getLocale()); current.setUsername(update.getUsername()); current.setTermsOfService(update.isTermsOfService()); userDao.updateUser(current);//w ww . jav a 2 s . c o m }
From source file:org.assertj.maven.generator.AssertionsGeneratorReport.java
private void reportEntryPointClassesGeneration(StringBuilder reportBuilder) { for (AssertionsEntryPointType type : assertionsEntryPointFilesByType.keySet()) { if (assertionsEntryPointFilesByType.get(type) != null) { String entryPointClassName = remove(type.getFileName(), ".java"); reportBuilder.append(System.lineSeparator()).append(entryPointClassName) .append(" entry point class has been generated in file:\n").append(INDENT) .append(assertionsEntryPointFilesByType.get(type).getAbsolutePath()) .append(System.lineSeparator()); }// w w w . jav a 2s .c o m } }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testNonExistingTargetFile() throws Exception { exit.expectSystemExitWithStatus(-1); exit.checkAssertionAfterwards(new Assertion() { @Override//from w w w. j a v a2 s. com public void checkAssertion() { assertEquals("Must specify files to process, found 0." + System.lineSeparator(), systemOut.getLog()); assertEquals("", systemErr.getLog()); } }); Main.main("-c", "/google_checks.xml", "NonExistingFile.java"); }