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.apache.reef.runtime.yarn.driver.restart.DFSEvaluatorPreserver.java
/** * Adds the removed evaluator entry to the evaluator log. * @param id/* www .j a v a 2 s .com*/ */ @Override public synchronized void recordRemovedEvaluator(final String id) { if (this.fileSystem != null && this.changeLogLocation != null) { final String entry = REMOVE_FLAG + id + System.lineSeparator(); this.logContainerChange(entry); } }
From source file:dpfmanager.shell.modules.report.core.ReportGenerator.java
/** * Read the file of the path.// w w w .ja v a 2 s. co m * * @param pathStr the file path to read. * @return the content of the file in path */ public String readFile(String pathStr) { String text = ""; String name = pathStr.substring(pathStr.lastIndexOf("/") + 1, pathStr.length()); Path path = Paths.get(pathStr); try { if (Files.exists(path)) { // Look in current dir BufferedReader br = new BufferedReader(new FileReader(pathStr)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } text = sb.toString(); br.close(); } else { // Look in JAR CodeSource src = ReportGenerator.class.getProtectionDomain().getCodeSource(); if (src != null) { URL jar = src.getLocation(); ZipInputStream zip; zip = new ZipInputStream(jar.openStream()); ZipEntry zipFile; boolean found = false; while ((zipFile = zip.getNextEntry()) != null && !found) { if (zipFile.getName().endsWith(name)) { BufferedReader br = new BufferedReader(new InputStreamReader(zip)); String line = br.readLine(); while (line != null) { text += line + System.lineSeparator(); line = br.readLine(); } found = true; } zip.closeEntry(); } } } } catch (FileNotFoundException e) { context.send(BasicConfig.MODULE_MESSAGE, new LogMessage(getClass(), Level.ERROR, "Template for html not found in dir.")); } catch (IOException e) { context.send(BasicConfig.MODULE_MESSAGE, new LogMessage(getClass(), Level.ERROR, "Error reading " + pathStr)); } return text; }
From source file:org.apache.metron.stellar.zeppelin.StellarInterpreterTest.java
/** * Ensure that we can run Stellar code in the interpreter. *///from w ww . j a va 2 s.com @Test public void testExecuteStellarMultipleLines() { // multi-line input String input = "x := 2 + 2" + System.lineSeparator() + "y := 4 + 4"; InterpreterResult result = interpreter.interpret(input, context); // expect x == 4 and y == 8 Map<String, VariableResult> vars = interpreter.getExecutor().getState(); assertEquals(4, vars.get("x").getResult()); assertEquals(8, vars.get("y").getResult()); // validate the result assertEquals(InterpreterResult.Code.SUCCESS, result.code()); assertEquals(1, result.message().size()); // the output is the result of only the 'last' expression InterpreterResultMessage message = result.message().get(0); assertEquals("8", message.getData()); assertEquals(InterpreterResult.Type.TEXT, message.getType()); }
From source file:chat.viska.xmpp.plugins.webrtc.WebRtcPlugin.java
@Nonnull private String convertSdpElementsToString(@Nonnull final Node sdpElement) { final StringBuilder sdp = new StringBuilder(); Observable.fromIterable(DomUtils.convertToList(sdpElement.getChildNodes())) .filter(it -> "line".equals(it.getLocalName())) .filter(it -> StringUtils.isNotBlank(it.getTextContent())).map(Node::getTextContent) .subscribe(it -> {/*from w w w . java 2s . c o m*/ sdp.append(it); sdp.append(System.lineSeparator()); }); return sdp.toString(); }
From source file:de.static_interface.sinklibrary.api.command.SinkCommand.java
private void sendUsage(CommandSender sender) { sender.sendMessage(getUsage().split(System.lineSeparator())); }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeTime.java
public Integer getKeep(JSONObject eideticParameters, Volume vol) { if ((eideticParameters == null) | (vol == null)) { return null; }/*w w w . ja va2 s . com*/ JSONObject createSnapshot = null; if (eideticParameters.containsKey("CreateSnapshot")) { createSnapshot = (JSONObject) eideticParameters.get("CreateSnapshot"); } if (createSnapshot == null) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); return null; } Integer keep = null; if (createSnapshot.containsKey("Retain")) { try { keep = Integer.parseInt(createSnapshot.get("Retain").toString()); } catch (Exception e) { logger.error("Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } return keep; }
From source file:com.ToResultSet.java
@Path("/tabelle") @GET//from w ww . j av a 2 s.c o m public String toResultSetTabelle(@QueryParam("budget") String x, @QueryParam("maxbudget") String y, @QueryParam("location") String location, @QueryParam("date") String minDateString) throws ParserConfigurationException, TransformerException, ParseException { ArrayList<String[]> result1 = new ArrayList<String[]>(); try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { System.out.println("Fehler bei MySQL-JDBC-Bridge" + e); } //SQL Query wird hier erzeugt je nach dem Daten, die angegeben werden try { int minBudget = 0; int maxBudget = 0; try { minBudget = Integer.valueOf(x); } catch (NumberFormatException e) { if (x.length() > 0) { return "Ihre Budget soll aus Zahlen bestehen"; } } try { maxBudget = Integer.valueOf(y); } catch (NumberFormatException e) { if (y.length() > 0) { return "Ihre Budget soll aus Zahlen bestehen"; } } try { test = Integer.valueOf(location); if (test >= 0) { return "Location soll aus String bestehen"; } } catch (Exception e) { } try { if (minDateString.substring(2, 3).contains("-") && minDateString.length() > 0) { return "Date Format soll yyyy-MM-dd"; } else { java.util.Date date1 = sdf.parse(minDateString); minDate = new java.sql.Date(date1.getTime()); } } catch (Exception e) { if (minDateString.length() > 0) return "Date Format soll yyyy-MM-dd"; } //Connection mit dem SQL wird erzeugt String url = "jdbc:mysql://" + host + "/" + dbName; connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/location?autoReconnect=true&useSSL=false", "root", "dreamhigh"); statement = connection.createStatement(); String sqlQuery = "Select * FROM " + dbTable; List<String> whereClause = new ArrayList<>(); if (minBudget > 0) { whereClause.add("Budget >= " + minBudget); } if (maxBudget > 0) { whereClause.add("Budget <= " + maxBudget); } if (minBudget > maxBudget && maxBudget > 0 && minBudget > 0) { return "Minimal Budget soll kleiner als Maximal Budget"; } if (minDate != null) { whereClause.add("Date >= '" + minDate + "'"); } if (location != null && !location.isEmpty()) { whereClause.add("Location = '" + location + "'"); } //Die Daten werden nach dem Budget absteigend sortiert if (whereClause.size() > 0) { sqlQuery += " WHERE " + StringUtils.join(whereClause, " AND ") + " ORDER BY Budget DESC"; } if (whereClause.size() == 0) { sqlQuery += " ORDER BY Budget DESC"; } resultSet = statement.executeQuery(sqlQuery); int spalten = resultSet.getMetaData().getColumnCount(); System.out.println("Anzahl Spalten: " + spalten); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); doc = builder.newDocument(); Element results = doc.createElement("Results"); doc.appendChild(results); connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/location?autoReconnect=true&useSSL=false", "root", "dreamhigh"); ResultSetMetaData rsmd = resultSet.getMetaData(); int colCount = rsmd.getColumnCount(); while (resultSet.next()) { String[] str = new String[6]; for (int k = 1; k <= spalten; k++) { str[k - 1] = resultSet.getString(k); if (result1.contains(str) == false) { result1.add(str); } } } //HTML Datei wird mit Hilfe von String Builder erzeugt sb.append("<html><body>"); for (Iterator iter = result1.iterator(); iter.hasNext();) { String[] str = (String[]) iter.next(); sb.append("<br>"); sb.append("<br>"); for (int i = 0; i < str.length; i++) { sb.append(System.lineSeparator()); if (i == 0) { sb.append("Link : <a href=" + str[i] + ">" + str[i] + "</a><br>"); } if (i == 1) { sb.append("Budget : " + str[i] + "<br>"); } if (i == 2) { sb.append("Location : " + str[i] + "<br>"); } if (i == 3) { sb.append("Qm : " + str[i] + "<br>"); } if (i == 4) { sb.append("Room : " + str[i] + "<br>"); } if (i == 5) { sb.append("Date : " + str[i] + "<br>"); } } } sb.append("</body>"); sb.append("</html>"); outPut = sb.toString(); } catch (SQLException e) { System.out.println("Fehler bei Tabellenabfrage: " + e); } return outPut = sb.toString(); }
From source file:de.hybris.vjdbc.VirtualDriverTest.java
private void assertFirstLineOfSQLException(final String message, final SQLException exception) { Assert.assertEquals(// w w w . j ava2s . c om "Expected to have message starting with [" + message + "] but got " + exception.getMessage(), message, StringUtils.split(exception.getMessage(), System.lineSeparator())[0]); }
From source file:com.github.christofluyten.experiment.MeasureGendreau.java
static <T extends Enum<?>> void write(Iterable<? extends Map<T, Object>> props, File dest, Iterable<T> keys) throws IOException { final StringBuilder sb = Joiner.on(",").appendTo(new StringBuilder(), keys).append(System.lineSeparator()); for (final Map<T, Object> row : props) { appendValuesTo(sb, row, keys).append(System.lineSeparator()); }//from ww w. j a va2 s .c om Files.write(sb.toString(), dest, Charsets.UTF_8); }