List of usage examples for org.apache.commons.lang3 SystemUtils LINE_SEPARATOR
String LINE_SEPARATOR
To view the source code for org.apache.commons.lang3 SystemUtils LINE_SEPARATOR.
Click Source Link
The line.separator System Property.
From source file:net.sfr.tv.mom.mgt.HornetqConsole.java
/** * @param args the command line arguments *//*from w ww.ja va 2s . c om*/ public static void main(String[] args) { try { String jmxHost = "127.0.0.1"; String jmxPort = "6001"; // Process command line arguments String arg; for (int i = 0; i < args.length; i++) { arg = args[i]; switch (arg) { case "-h": jmxHost = args[++i]; break; case "-p": jmxPort = args[++i]; break; default: break; } } // Check for arguments consistency if (StringUtils.isEmpty(jmxHost) || !NumberUtils.isNumber(jmxPort)) { LOGGER.info("Usage : "); LOGGER.info("hq-console.jar <-h host(127.0.0.1)> <-p port(6001)>\n"); System.exit(1); } System.out.println( SystemUtils.LINE_SEPARATOR.concat(Ansi.format("HornetQ Console ".concat(VERSION), Color.CYAN))); final StringBuilder _url = new StringBuilder("service:jmx:rmi://").append(jmxHost).append(':') .append(jmxPort).append("/jndi/rmi://").append(jmxHost).append(':').append(jmxPort) .append("/jmxrmi"); final String jmxServiceUrl = _url.toString(); JMXConnector jmxc = null; final CommandRouter router = new CommandRouter(); try { jmxc = JMXConnectorFactory.connect(new JMXServiceURL(jmxServiceUrl), null); assert jmxc != null; // jmxc must be not null } catch (final MalformedURLException e) { System.out.println(SystemUtils.LINE_SEPARATOR .concat(Ansi.format(jmxServiceUrl + " :" + e.getMessage(), Color.RED))); } catch (Throwable t) { System.out.println(SystemUtils.LINE_SEPARATOR.concat( Ansi.format("Unable to connect to JMX service URL : ".concat(jmxServiceUrl), Color.RED))); System.out.print(SystemUtils.LINE_SEPARATOR.concat( Ansi.format("Did you add jmx-staticport-agent.jar to your classpath ?", Color.MAGENTA))); System.out.println(SystemUtils.LINE_SEPARATOR.concat(Ansi.format( "Or did you set the com.sun.management.jmxremote.port option in the hornetq server startup script ?", Color.MAGENTA))); System.exit(-1); } System.out.println("\n".concat(Ansi .format("Successfully connected to JMX service URL : ".concat(jmxServiceUrl), Color.YELLOW))); final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); // PRINT SERVER STATUS REPORT System.out.print((String) router.get(Command.STATUS, Option.VM).execute(mbsc, null)); System.out.print((String) router.get(Command.STATUS, Option.SERVER).execute(mbsc, null)); System.out.print((String) router.get(Command.STATUS, Option.CLUSTER).execute(mbsc, null)); printHelp(router); // START COMMAND LINE Scanner scanner = new Scanner(System.in); System.out.print("> "); String input; while (!(input = scanner.nextLine().concat(" ")).equals("exit ")) { String[] cliArgs = input.split("\\ "); CommandHandler handler; if (cliArgs.length < 1) { System.out.print("> "); continue; } Command cmd = Command.fromString(cliArgs[0]); if (cmd == null) { System.out.print(Ansi.format("Syntax error !", Color.RED).concat("\n")); cmd = Command.HELP; } switch (cmd) { case STATUS: case LIST: case DROP: Set<Option> options = router.get(cmd); for (Option opt : options) { if (cliArgs[1].equals(opt.toString())) { handler = router.get(cmd, opt); String[] cmdOpts = null; if (cliArgs.length > 2) { cmdOpts = new String[cliArgs.length - 2]; for (int i = 0; i < cmdOpts.length; i++) { cmdOpts[i] = cliArgs[2 + i]; } } Object result = handler.execute(mbsc, cmdOpts); if (result != null && String.class.isAssignableFrom(result.getClass())) { System.out.print((String) result); } System.out.print("> "); } } break; case FORK: // EXECUTE SYSTEM COMMAND ProcessBuilder pb = new ProcessBuilder(Arrays.copyOfRange(cliArgs, 1, cliArgs.length)); pb.inheritIO(); pb.start(); break; case HELP: printHelp(router); break; } } } catch (MalformedURLException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (IOException ex) { LOGGER.log(Level.SEVERE, null, ex); } echo(SystemUtils.LINE_SEPARATOR.concat(Ansi.format("Bye!", Color.CYAN))); }
From source file:edu.usf.cutr.obascs.io.ConfigFileGenerator.java
public static String generateStopConsolidationScriptConfigFile(String configXml, Map<String, String> agencyMap) { StringBuilder bundleNamesBuilder = new StringBuilder(); StringBuilder gtfsBeansBuilder = new StringBuilder(); for (Map.Entry<String, String> agency : agencyMap.entrySet()) { bundleNamesBuilder.append("<ref bean=\"gtfs_").append(agency.getValue()).append("\" />") .append(SystemUtils.LINE_SEPARATOR); gtfsBeansBuilder.append("<bean id=\"gtfs-").append(agency.getValue()) .append("\" class=\"org.onebusaway.transit_data_federation.bundle.model.GtfsBundle\">"); gtfsBeansBuilder.append(SystemUtils.LINE_SEPARATOR); gtfsBeansBuilder.append("<property name=\"path\" value=\"${bundle.root}/").append(agency.getValue()) .append("/final\" />"); gtfsBeansBuilder.append(SystemUtils.LINE_SEPARATOR); gtfsBeansBuilder.append("<property name=\"defaultAgencyId\" value=\"").append(agency.getKey()) .append("\" />"); gtfsBeansBuilder.append(SystemUtils.LINE_SEPARATOR); gtfsBeansBuilder.append(" </bean>"); }//w w w . j ava2s . c om configXml = StringUtils.replace(configXml, "${bundleNames}", bundleNamesBuilder.toString()); configXml = StringUtils.replace(configXml, "${gtfsBeans}", gtfsBeansBuilder.toString()); return configXml; }
From source file:edu.usf.cutr.obascs.io.FileConsolidator.java
public static String consolidateFile(ListFeed feed, Map<String, String> agencyMap) { Logger logger = Logger.getInstance(); logger.debug("Merging files started..."); logger.debug("Total Entries : " + feed.getEntries().size()); StringBuilder sb = new StringBuilder("#summary HART consolidated stops"); sb.append(SystemUtils.LINE_SEPARATOR).append(SystemUtils.LINE_SEPARATOR); sb.append(StringConstants.FILE_START).append(SystemUtils.LINE_SEPARATOR).append(SystemUtils.LINE_SEPARATOR); for (ListEntry entry : feed.getEntries()) { /*//from ww w .j a v a 2s.c o m * lineCounter: to separate columns by tab character */ Integer lineCounter = 0; for (Map.Entry<String, String> agency : agencyMap.entrySet()) { String stopId = StringUtils .trim(entry.getCustomElements().getValue(StringUtils.deleteWhitespace(agency.getKey()))); if (lineCounter == 0) { if (StringUtils.isNotBlank(stopId)) { sb.append("\"").append(agency.getKey()).append(StringConstants.UNDERSCORE).append(stopId) .append("\"").append(StringConstants.TAB); } } else if (lineCounter == agencyMap.size() - 2) { if (StringUtils.isNotBlank(stopId)) { sb.append("\"").append(agency.getKey()).append(StringConstants.UNDERSCORE).append(stopId) .append("\""); } } else { if (StringUtils.isNotBlank(stopId)) { sb.append("\"").append(agency.getKey()).append(StringConstants.UNDERSCORE).append(stopId) .append("\"").append(StringConstants.TAB); } else { sb.append(StringConstants.TAB); } } lineCounter++; } sb.append(SystemUtils.LINE_SEPARATOR); } sb.append(SystemUtils.LINE_SEPARATOR).append(StringConstants.FILE_END); logger.debug("Merge finished"); return sb.toString(); }
From source file:de.vandermeer.asciitable.commons.Table_ToStringStyle.java
/** * Returns the toString() style.//from www . j av a 2 s .co m * @return common style for toString() methods */ public static final ToStringStyle configure() { StandardToStringStyle ret = new StandardToStringStyle(); ret.setUseShortClassName(true); //don't like long class names ret.setFieldNameValueSeparator(" = "); // some spaces help readability ret.setArrayContentDetail(true); // arrays w/ details ret.setDefaultFullDetail(true); ret.setContentStart("["); ret.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " "); ret.setFieldSeparatorAtStart(true); ret.setContentEnd(SystemUtils.LINE_SEPARATOR + "]"); return ret; }
From source file:de.vandermeer.asciitable.commons.ObjectToStringStyle.java
/** * Returns a standard toString() style.//w w w . j a va2 s. c o m * @param indent indentation in number of characters, useful for nested operations * @return common style for toString() methods */ public static final ToStringStyle getStyle(int indent) { StandardToStringStyle ret = new StandardToStringStyle(); ret.setUseShortClassName(true); //don't like long class names ret.setFieldNameValueSeparator(" = "); // some spaces help readability ret.setArrayContentDetail(true); // arrays w/ details ret.setDefaultFullDetail(true); String indentation = ""; for (int i = 0; i <= indent; i++) { indentation += " "; } ret.setContentStart("["); ret.setFieldSeparator(SystemUtils.LINE_SEPARATOR + indentation + " "); ret.setFieldSeparatorAtStart(true); ret.setContentEnd(SystemUtils.LINE_SEPARATOR + indentation + "]"); return ret; }
From source file:com.feilong.commons.core.util.StringBuilderUtil.java
/** * append ?./* w w w. j a v a 2s . c om*/ * * @param stringBuilder * stringBuilder * @param text * ?append */ public static final void appendTextWithLn(StringBuilder stringBuilder, Object text) { stringBuilder.append(text); stringBuilder.append(SystemUtils.LINE_SEPARATOR); }
From source file:mbenson.annotationprocessing.util.CodeModel.java
/** * Add (potentially multiline) {@code commentary} to {@code commentPart}. * // w ww. j a va 2 s. co m * @param commentPart * @param commentary */ public static void addTo(JCommentPart commentPart, String... commentary) { if (commentary != null) { for (String s : commentary) { commentPart.add(s); commentPart.add(SystemUtils.LINE_SEPARATOR); } } }
From source file:net.sfr.tv.mom.mgt.CommandHandler.java
protected StringBuilder getOutput() { StringBuilder output = new StringBuilder(); if (title != null) { output.append(SystemUtils.LINE_SEPARATOR).append(Ansi.format("# ".concat(title), Ansi.Color.GREEN)) .append(" : ").append(SystemUtils.LINE_SEPARATOR); }/*from ww w . j av a2s .com*/ return output; }
From source file:com.discovery.darchrow.io.ReaderUtil.java
/** * {@link java.io.Reader} ? {@link java.lang.String}. * * @param reader//from w ww . j a v a 2 s . c om * the reader * @return the string * @see org.apache.commons.io.IOUtils#toBufferedReader(Reader) */ public static String toString(Reader reader) { BufferedReader bufferedReader = org.apache.commons.io.IOUtils.toBufferedReader(reader); try { StringBuilder sb = new StringBuilder(); String line = ""; // ?.???? ('\n')? ('\r') ???. while ((line = bufferedReader.readLine()) != null) { sb.append(line); sb.append(SystemUtils.LINE_SEPARATOR); } return sb.toString(); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.feilong.commons.core.io.ReaderUtil.java
/** * bufferedReader ? string.//w w w . ja v a 2 s . c om * * @param reader * the reader * @return the string * @throws UncheckedIOException * the unchecked io exception * @see org.apache.commons.io.IOUtils#toBufferedReader(Reader) */ public static String toString(Reader reader) throws UncheckedIOException { BufferedReader bufferedReader = IOUtils.toBufferedReader(reader); try { StringBuilder sb = new StringBuilder(); String line = ""; // ?.???? ('\n')? ('\r') ???. while ((line = bufferedReader.readLine()) != null) { sb.append(line); sb.append(SystemUtils.LINE_SEPARATOR); } return sb.toString(); } catch (IOException e) { throw new UncheckedIOException(e); } }