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:ddf.catalog.impl.operations.DeleteOperations.java
private String buildDeleteLog(DeleteResponse deleteResponse) { StringBuilder strBuilder = new StringBuilder(); List<Metacard> metacards = deleteResponse.getDeletedMetacards(); String metacardTitleLabel = "Metacard Title: "; String metacardIdLabel = "Metacard ID: "; for (int i = 0; i < metacards.size(); i++) { Metacard card = metacards.get(i); strBuilder.append(System.lineSeparator()).append("Batch #: ").append(i + 1).append(" | "); if (card != null) { if (card.getTitle() != null) { strBuilder.append(metacardTitleLabel).append(card.getTitle()).append(" | "); }/*from ww w. j av a 2 s.c om*/ if (card.getId() != null) { strBuilder.append(metacardIdLabel).append(card.getId()).append(" | "); } } else { strBuilder.append("Null Metacard"); } } return strBuilder.toString(); }
From source file:org.caboclo.util.Credentials.java
/** * Deletes the access credentials of the specified cloud provider on * credentials database file/*from w ww .j a va 2 s. c om*/ * * @param server */ public void removeCredentials(String server) { StringBuilder path = new StringBuilder(); path.append(System.getProperty("user.home")).append(java.io.File.separator).append("backupcredentials"); BufferedReader input; try { //Create file if it does not exist File credFile = new File(path.toString()); if (!credFile.exists()) { credFile.createNewFile(); } //Stores contents of credentials file, except by line for the //specified cloud server input = new BufferedReader(new FileReader(credFile)); StringBuilder builder = new StringBuilder(); while (input.ready()) { String line = input.readLine(); System.out.println("Cred line: " + line); if (!line.startsWith(server)) { System.out.println("Not-deleted line: " + line); builder.append(line).append(System.lineSeparator()); } } input.close(); //Write new contents in the credentials file BufferedWriter output = new BufferedWriter(new FileWriter(credFile)); output.write(builder.toString()); output.flush(); output.close(); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeTime.java
public boolean snapshotCreation(AmazonEC2Client ec2Client, Volume vol, String period, Date date) { if ((date == null) | (ec2Client == null) | (vol == null) | (period == null)) { return false; }/*from w w w.java 2 s .com*/ try { if ("day".equalsIgnoreCase(period)) { } else if ("hour".equalsIgnoreCase(period)) { } else if ("week".equalsIgnoreCase(period)) { } else if ("month".equalsIgnoreCase(period)) { } else { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); return false; } Collection<Tag> tags_volume = getResourceTags(vol); String volumeAttachmentInstance = "none"; try { volumeAttachmentInstance = vol.getAttachments().get(0).getInstanceId(); } catch (Exception e) { logger.debug("Volume not attached to instance: " + vol.getVolumeId()); } String description = period + "_snapshot " + vol.getVolumeId() + " by Eidetic at " + date.toString() + ". Volume attached to " + volumeAttachmentInstance; Snapshot current_snap; try { current_snap = createSnapshotOfVolume(ec2Client, vol, description, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); return false; } try { setResourceTags(ec2Client, current_snap, tags_volume, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event\"Error\", Error=\"error adding tags to snapshot\", Snapshot_id=\"" + current_snap.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); return false; } } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error, Error=\"error in snapshotCreation\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); return false; } return true; }
From source file:faescapeplan.FAEscapePlanUI.java
private String removeHtmlTags(String rawText) { String body = rawText;//from w ww. j a v a 2 s . c o m body = body.replaceAll("<br>\\s*" + System.lineSeparator(), "") .replaceAll("<br>\\s*", System.lineSeparator()).replaceAll("<[^>]*>", ""); return body; }
From source file:com.glluch.ecf2xmlmaven.Competence.java
protected String rterms2xml(String field_name) { String text = ""; if (related.isEmpty()) return ""; Set rterms = related.keySet(); for (Object t : rterms) { text += "<field name=\"" + field_name + "\" " + " boost=\"" + related_boost * related.get(t) + "\"" + ">" + t + "</field>" + System.lineSeparator(); }/* w ww . j a v a2s . c om*/ return text; }
From source file:com.oneops.inductor.Listener.java
/** * clear state file by thread id/* w w w . jav a2 s.c o m*/ */ private void clearStateFile() { String filename = getStateFileName(); String content = "idle" + System.lineSeparator(); content += System.currentTimeMillis(); writeStateFile(filename, content); }
From source file:org.apache.pulsar.functions.runtime.RuntimeUtils.java
public static String getPrometheusMetrics(int metricsPort) throws IOException { StringBuilder result = new StringBuilder(); URL url = new URL(String.format("http://%s:%s", InetAddress.getLocalHost().getHostAddress(), metricsPort)); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line;/*from w w w .ja v a 2 s . co m*/ while ((line = rd.readLine()) != null) { result.append(line + System.lineSeparator()); } rd.close(); return result.toString(); }
From source file:net.cyllene.hackerrank.downloader.HackerrankDownloader.java
/** * Gets a secret key from configuration file in user.home. * The secret key is a _hackerrank_session variable stored in cookies by server. * To simplify things, no login logic is present in this program, it means * you should login somewhere else and then provide this value in the config. * * @return String representing a _hackerrank_session id, about 430 characters long. *//*from ww w. j a v a2 s .c om*/ private static String getSecretFromConfig() { final String confPathStr = System.getProperty("user.home") + File.separator + DownloaderSettings.KEYFILE_NAME; final Path confPath = Paths.get(confPathStr); String result = null; try { result = Files.readAllLines(confPath, StandardCharsets.US_ASCII).get(0); } catch (IOException e) { System.err.println("Fatal Error: Unable to open configuration file " + confPathStr + System.lineSeparator() + "File might be missing, empty or inaccessible by user." + System.lineSeparator() + "It must contain a single ASCII line, a value of \"" + DownloaderSettings.SECRET_COOKIE_ID + "\" cookie variable," + System.lineSeparator() + "which length is about 430 symbols."); System.exit(1); } return result; }
From source file:com.pearson.eidetic.driver.threads.RefreshAwsAccountVolumes.java
private HashMap<Integer, ConcurrentHashMap<Region, ArrayList<Volume>>> refreshCreateSnapshotVolumes( Volume volume, JSONObject createSnapshot, ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeTime, ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeNoTime, Region region) { HashMap<Integer, ConcurrentHashMap<Region, ArrayList<Volume>>> resultSet = new HashMap(); //New volume detected! Return value continue if (!localVolumeNoTime.get(region).contains(volume) && !localVolumeTime.get(region).contains(volume)) { if (createSnapshot.containsKey("RunAt")) {//Add tries try { localVolumeTime.get(region).add(volume); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error adding vol to VolumeTime_\", Volume_id=\"" + volume.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); }//www . j av a 2s. co m volTimeHasTag_.put(volume, true); } else { try { localVolumeNoTime.get(region).add(volume); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error adding vol to VolumeTime_\", Volume_id=\"" + volume.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } volNoTimeHasTag_.put(volume, true); } resultSet.put(0, localVolumeTime); resultSet.put(1, localVolumeNoTime); return resultSet; } //Old volume Tag is left unchanged if ((createSnapshot.containsKey("RunAt")) && localVolumeTime.get(region).contains(volume)) { volTimeHasTag_.replace(volume, true); } else if (!(createSnapshot.containsKey("RunAt")) && localVolumeNoTime.get(region).contains(volume)) { volNoTimeHasTag_.replace(volume, true); //If we change the value of the tag. } else if ((createSnapshot.containsKey("RunAt")) && localVolumeNoTime.get(region).contains(volume)) { volTimeHasTag_.put(volume, true); volNoTimeHasTag_.replace(volume, false); try { localVolumeTime.get(region).add(volume); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error adding vol to VolumeNoTime_\", Volume_id=\"" + volume.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } else if (!(createSnapshot.containsKey("RunAt")) && localVolumeTime.get(region).contains(volume)) { volNoTimeHasTag_.put(volume, true); volTimeHasTag_.replace(volume, false); try { localVolumeNoTime.get(region).add(volume); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error adding vol to VolumeNoTime_\", Volume_id=\"" + volume.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } else { logger.error( "Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + volume.getVolumeId() + "\""); } resultSet.put(0, localVolumeTime); resultSet.put(1, localVolumeNoTime); return resultSet; }
From source file:de.fosd.jdime.common.FileArtifact.java
@Override protected final String dumpTree(final String indent) { StringBuilder sb = new StringBuilder(); Matching<FileArtifact> m = null; if (hasMatches()) { Set<Revision> matchingRevisions = matches.keySet(); // print color code String color = ""; for (Revision rev : matchingRevisions) { m = getMatching(rev);//from w w w . j av a 2 s. c om color = m.getColor().toShell(); } sb.append(color); } sb.append(indent).append("(").append(getId()).append(") "); sb.append(this); if (hasMatches()) { assert (m != null); sb.append(" <=> (").append(m.getMatchingArtifact(this)).append(")"); sb.append(Color.DEFAULT.toShell()); } sb.append(System.lineSeparator()); if (!isLeaf()) { // children for (FileArtifact child : getChildren()) { sb.append(child.dumpTree(indent + " ")); } } return sb.toString(); }