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:com.glluch.ecf2xmlmaven.Competence.java
protected String terms2xml(String field_name) { String text = ""; Set pterms = terms.keySet();/*from ww w . j a v a 2s . c om*/ for (Object t : pterms) { text += "<field name=\"" + field_name + "\" " + " boost=\"" + term_boost * terms.get(t) + "\"" + ">" + t + "</field>" + System.lineSeparator(); } return text; }
From source file:com.firewallid.networkanalysis.NetworkAnalysis.java
public void saveNAFileEdges(JavaPairRDD<String, Set<Tuple2<String, String>>> edges, String prefixFileName) { String docDelimiter = StringEscapeUtils.unescapeJava(firewallConf.get(DOC_DELIMITER)); String naFolder = firewallConf.get(NETWORKANALYSIS_FOLDER); String nameDelimiter = firewallConf.get(NAME_DELIMITER); edges.mapToPair(edge -> new Tuple2<>(edge._1(), "id" + docDelimiter + "node1" + docDelimiter + "node2" + System.lineSeparator() + StreamUtils.zipWithIndex(edge._2().parallelStream()).parallel() .map(edgeItem -> edgeItem.getIndex() + docDelimiter + edgeItem.getValue()._1() + docDelimiter + edgeItem.getValue()._2()) .collect(Collectors.joining(System.lineSeparator())))) .foreach(edge -> FIFile.writeStringToHDFSFile( FIFile.generateFullPath(naFolder, prefixFileName + nameDelimiter + edge._1() + nameDelimiter + "edge.csv"), edge._2()));// ww w. ja va 2 s . c o m }
From source file:com.netflix.genie.core.jobs.workflow.impl.InitialSetupTask.java
@VisibleForTesting void createClusterEnvironmentVariables(final Writer writer, final Cluster cluster) throws GenieException, IOException { final String clusterId = cluster.getId().orElseThrow(() -> new GenieServerException("No cluster id")); writer.write(JobConstants.EXPORT + JobConstants.GENIE_CLUSTER_DIR_ENV_VAR + JobConstants.EQUALS_SYMBOL + JobConstants.DOUBLE_QUOTE_SYMBOL + "${" + JobConstants.GENIE_JOB_DIR_ENV_VAR + "}" + JobConstants.FILE_PATH_DELIMITER + JobConstants.GENIE_PATH_VAR + JobConstants.FILE_PATH_DELIMITER + JobConstants.CLUSTER_PATH_VAR + JobConstants.FILE_PATH_DELIMITER + clusterId + JobConstants.DOUBLE_QUOTE_SYMBOL + LINE_SEPARATOR); // Append new line writer.write(System.lineSeparator()); writer.write(JobConstants.EXPORT + JobConstants.GENIE_CLUSTER_ID_ENV_VAR + JobConstants.EQUALS_SYMBOL + JobConstants.DOUBLE_QUOTE_SYMBOL + clusterId + JobConstants.DOUBLE_QUOTE_SYMBOL + LINE_SEPARATOR); // Append new line writer.write(System.lineSeparator()); writer.write(JobConstants.EXPORT + JobConstants.GENIE_CLUSTER_NAME_ENV_VAR + JobConstants.EQUALS_SYMBOL + JobConstants.DOUBLE_QUOTE_SYMBOL + cluster.getName() + JobConstants.DOUBLE_QUOTE_SYMBOL + LINE_SEPARATOR);/*from w w w .j ava 2 s. co m*/ // Append new line writer.write(System.lineSeparator()); writer.write(JobConstants.EXPORT + JobConstants.GENIE_CLUSTER_TAGS_ENV_VAR + JobConstants.EQUALS_SYMBOL + JobConstants.DOUBLE_QUOTE_SYMBOL + this.tagsToString(cluster.getTags()) + JobConstants.DOUBLE_QUOTE_SYMBOL + LINE_SEPARATOR); // Append new line writer.write(System.lineSeparator()); }
From source file:carisma.ui.eclipse.CarismaGUI.java
/** * //from w ww . j av a 2 s . c o m * @param analysisResult * the analysis result * */ /* * * Currently changed to output HTML-Files */ public final static void openReport(final AnalysisResult analysisResult) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IContainer container = analysisResult.getAnalysis().getIFile().getParent(); IFile file = null; if (container instanceof IFolder) { IFolder folder = (IFolder) container; file = folder .getFile("report-" + analysisResult.getName() + "-" + analysisResult.getTimestamp() + ".html"); // changedfrom // txt } else if (container instanceof IProject) { IProject project = (IProject) container; file = project .getFile("report-" + analysisResult.getName() + "-" + analysisResult.getTimestamp() + ".html"); // changedfrom // txt } else { Logger.log(LogLevel.ERROR, "Analyzed file is not part of a project."); return; } // new... String htmlOpen = "<!DOCTYPE html>\n" + "<html lang=\"de\">\n" + "<head>\n" + "\t<meta charset=\"utf-8\">\n" + "\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" + "\t<title>CARiSMA Report</title>\n" + "</head>\n" + "<body>\n" + "\t<p>\n\t"; String htmlClose = "</p>\n" + "</body>\n" + "</html>"; String htmlBody = StringEscapeUtils.escapeHtml4(analysisResult.getReport()); htmlBody = htmlBody.replace("\t", " ").replaceAll("\\r|\\n", "<br/>" + System.lineSeparator() + "\t"); String html = (htmlOpen + htmlBody + htmlClose); try { if (!(file.exists())) { //file.create(Utils.createInputStreamFromString(analysisResult.getReport()), true, null); file.create(StringInputStream.createInputStreamFromString(html), true, null); } IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName()); try { page.openEditor(new FileEditorInput(file), desc.getId()); } catch (PartInitException e) { Logger.log(LogLevel.ERROR, "Could not start editor, \"" + desc.getId() + "\".", e); } } catch (CoreException e) { Logger.log(LogLevel.ERROR, "", e); } }
From source file:com.liferay.blade.cli.command.InstallExtensionCommandTest.java
private static void _testJarsDiff(File warFile1, File warFile2) throws IOException { DifferenceCalculator differenceCalculator = new DifferenceCalculator(warFile1, warFile2); differenceCalculator.setFilenameRegexToIgnore(Collections.singleton(".*META-INF.*")); differenceCalculator.setIgnoreTimestamps(true); Differences differences = differenceCalculator.getDifferences(); if (!differences.hasDifferences()) { return;//ww w. j a v a 2s . c o m } StringBuilder message = new StringBuilder(); message.append("WAR "); message.append(warFile1); message.append(" and "); message.append(warFile2); message.append(" do not match:"); message.append(System.lineSeparator()); boolean realChange; Map<String, ZipArchiveEntry> added = differences.getAdded(); Map<String, ZipArchiveEntry[]> changed = differences.getChanged(); Map<String, ZipArchiveEntry> removed = differences.getRemoved(); if (added.isEmpty() && !changed.isEmpty() && removed.isEmpty()) { realChange = false; ZipFile zipFile1 = null; ZipFile zipFile2 = null; try { zipFile1 = new ZipFile(warFile1); zipFile2 = new ZipFile(warFile2); for (Map.Entry<String, ZipArchiveEntry[]> entry : changed.entrySet()) { ZipArchiveEntry[] zipArchiveEntries = entry.getValue(); ZipArchiveEntry zipArchiveEntry1 = zipArchiveEntries[0]; ZipArchiveEntry zipArchiveEntry2 = zipArchiveEntries[0]; if (zipArchiveEntry1.isDirectory() && zipArchiveEntry2.isDirectory() && (zipArchiveEntry1.getSize() == zipArchiveEntry2.getSize()) && (zipArchiveEntry1.getCompressedSize() <= 2) && (zipArchiveEntry2.getCompressedSize() <= 2)) { // Skip zipdiff bug continue; } try (InputStream inputStream1 = zipFile1 .getInputStream(zipFile1.getEntry(zipArchiveEntry1.getName())); InputStream inputStream2 = zipFile2 .getInputStream(zipFile2.getEntry(zipArchiveEntry2.getName()))) { List<String> lines1 = StringTestUtil.readLines(inputStream1); List<String> lines2 = StringTestUtil.readLines(inputStream2); message.append(System.lineSeparator()); message.append("--- "); message.append(zipArchiveEntry1.getName()); message.append(System.lineSeparator()); message.append("+++ "); message.append(zipArchiveEntry2.getName()); message.append(System.lineSeparator()); Patch<String> diff = DiffUtils.diff(lines1, lines2); for (Delta<String> delta : diff.getDeltas()) { message.append('\t'); message.append(delta.getOriginal()); message.append(System.lineSeparator()); message.append('\t'); message.append(delta.getRevised()); message.append(System.lineSeparator()); } } realChange = true; break; } } finally { ZipFile.closeQuietly(zipFile1); ZipFile.closeQuietly(zipFile2); } } else { realChange = true; } Assert.assertFalse(message.toString(), realChange); }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeNoTime.java
public boolean snapshotDecision(AmazonEC2Client ec2Client, Volume vol, String period) { if ((ec2Client == null) || (vol == null) || (period == null)) { return false; }//from w w w . j a v a 2s. c om try { List<Snapshot> int_snapshots = getAllSnapshotsOfVolume(ec2Client, vol, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); List<Snapshot> comparelist = new ArrayList(); for (Snapshot snapshot : int_snapshots) { String sndesc = snapshot.getDescription(); if ("week".equalsIgnoreCase(period) && sndesc.startsWith("week_snapshot")) { comparelist.add(snapshot); } else if ("day".equalsIgnoreCase(period) && sndesc.startsWith("day_snapshot")) { comparelist.add(snapshot); } else if ("hour".equalsIgnoreCase(period) && sndesc.startsWith("hour_snapshot")) { comparelist.add(snapshot); } else if ("month".equalsIgnoreCase(period) && sndesc.startsWith("month_snapshot")) { comparelist.add(snapshot); } } List<Snapshot> sortedCompareList = new ArrayList<>(comparelist); sortSnapshotsByDate(sortedCompareList); int hours = getHoursBetweenNowAndNewestSnapshot(sortedCompareList); int days = getDaysBetweenNowAndNewestSnapshot(sortedCompareList); if (("week".equalsIgnoreCase(period) && days < 0) || ("week".equalsIgnoreCase(period) && days >= 7)) { } else if (("hour".equalsIgnoreCase(period) && hours < 0) || ("hour".equalsIgnoreCase(period) && hours >= 1)) { } else if (("day".equalsIgnoreCase(period) && days < 0) || ("day".equalsIgnoreCase(period) && days >= 1)) { } else if (("month".equalsIgnoreCase(period) && days < 0) || ("month".equalsIgnoreCase(period) && days >= 30)) { } else { return false; } } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in snapshotDecision\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); return false; } return true; }
From source file:com.redhat.jenkins.nodesharing.NodeSharingJenkinsRule.java
@Nonnull private String getJenkinsfileContent(String url) { StringBuilder sb = new StringBuilder("url=").append(url).append(System.lineSeparator()); if (url.startsWith("http://")) { sb.append("enforce_https=false").append(System.lineSeparator()); }/*from w w w . ja v a 2s . co m*/ return sb.toString(); }
From source file:de.fosd.jdime.common.ASTNodeArtifact.java
@Override protected final String dumpTree(final String indent) { assert (astnode != null); StringBuilder sb = new StringBuilder(); // node itself Matching<ASTNodeArtifact> m = null; // color// ww w .j av a 2 s. co m if (!isConflict() && hasMatches()) { Set<Revision> matchingRevisions = matches.keySet(); // print color code String color = ""; for (Revision rev : matchingRevisions) { m = getMatching(rev); color = m.getColor().toShell(); } sb.append(color); } if (isConflict()) { sb.append(Color.RED.toShell()); sb.append(indent).append("(").append(getId()).append(") "); sb.append(this); sb.append(System.lineSeparator()); sb.append(Color.RED.toShell()); sb.append("<<<<<<< "); sb.append(System.lineSeparator()); // children if (left != null) { sb.append(left.dumpTree(indent)); } sb.append(Color.RED.toShell()); sb.append("======= "); sb.append(System.lineSeparator()); // children if (right != null) { sb.append(right.dumpTree(indent)); } sb.append(Color.RED.toShell()); sb.append(">>>>>>> "); sb.append(System.lineSeparator()); } else { sb.append(indent).append("(").append(getId()).append(") "); sb.append(this); if (hasMatches()) { assert (m != null); sb.append(" <=> (").append(m.getMatchingArtifact(this).getId()).append(")"); sb.append(Color.DEFAULT.toShell()); } sb.append(System.lineSeparator()); // children for (ASTNodeArtifact child : getChildren()) { sb.append(child.dumpTree(indent + " ")); } } return sb.toString(); }
From source file:de.fraunhofer.iosb.ivct.IVCTcommander.java
public static String readWholeFile(final String filename) { BufferedReader br = null;/*from ww w . j a va 2s . c o m*/ String everything = null; File myFile = new File(filename); if (myFile.isFile() == false) { return everything; } try { br = new BufferedReader(new FileReader(filename)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } everything = sb.toString(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { } } } return everything; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeSync.java
public boolean snapshotDeletion(AmazonEC2Client ec2Client, Volume vol, Integer keep) { if ((keep == null) || (ec2Client == null) || (vol == null)) { return false; }/*from w w w . ja va 2 s . c o m*/ try { List<Snapshot> del_snapshots = getAllSnapshotsOfVolume(ec2Client, vol, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); List<Snapshot> deletelist = new ArrayList(); for (Snapshot snapshot : del_snapshots) { String desc = snapshot.getDescription(); if (desc.startsWith("sync_snapshot")) { deletelist.add(snapshot); } } List<Snapshot> sortedDeleteList = new ArrayList<>(deletelist); sortSnapshotsByDate(sortedDeleteList); int delta = sortedDeleteList.size() - keep; for (int i : range(0, delta - 1)) { try { deleteSnapshot(ec2Client, sortedDeleteList.get(i), numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error deleting snapshot\", Snapshot_id=\"" + sortedDeleteList.get(i).getSnapshotId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in snapshotDeletion\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } return true; }