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:nl.sidn.pcap.ip.AbstractNetworkCheck.java
private void writeToFile(File file) throws IOException { if (!file.exists()) { file.createNewFile();/* w w w . j a va2s.com*/ } String sep = System.lineSeparator(); FileWriter fw = new FileWriter(file.getAbsoluteFile(), false); BufferedWriter bw = new BufferedWriter(fw); for (String range : subnets) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Write resolver " + range + " to file: " + file.getAbsolutePath()); } bw.write(range); bw.write(sep); } bw.close(); }
From source file:com.adguard.compiler.LocaleUtils.java
public static void writeLocalesToFirefoxInstallRdf(File dest, String extensionNamePostfix) throws IOException { // <em:localized> // <Description> // <em:locale>en</em:locale> // <em:name>Adguard AdBlocker</em:name> // <em:description>Adguard AdBlocker</em:description> // </Description> // </em:localized> File installManifest = new File(dest, "install.rdf"); if (!installManifest.exists()) { return;//w w w . ja v a2 s . c o m } StringBuilder sb = new StringBuilder(); for (SupportedLocales locale : SupportedLocales.values()) { File localeFile = new File(dest, "locale/" + locale.code.replace("_", "-") + ".properties"); String[] messages = StringUtils.split(FileUtils.readFileToString(localeFile), System.lineSeparator()); String name = findMessage(messages, "name") + extensionNamePostfix; String description = findMessage(messages, "description"); sb.append("<em:localized>").append(System.lineSeparator()); sb.append("\t<Description>").append(System.lineSeparator()); sb.append("\t\t<em:locale>").append(locale.code).append("</em:locale>").append(System.lineSeparator()); sb.append("\t\t<em:name>").append(name).append("</em:name>").append(System.lineSeparator()); sb.append("\t\t<em:description>").append(description).append("</em:description>") .append(System.lineSeparator()); sb.append("\t</Description>").append(System.lineSeparator()); sb.append("</em:localized>").append(System.lineSeparator()); } String content = FileUtils.readFileToString(installManifest); content = StringUtils.replace(content, "${localised}", sb.toString()); FileUtils.writeStringToFile(installManifest, content, "utf-8"); }
From source file:org.apache.apex.malhar.sql.FileEndpointTest.java
private boolean waitTillStdoutIsPopulated(ByteArrayOutputStream baos, int timeout) throws InterruptedException, IOException { long now = System.currentTimeMillis(); Collection<String> filter = Lists.newArrayList(); while (System.currentTimeMillis() - now < timeout) { baos.flush();// www .j a va2 s . c o m String[] sout = baos.toString().split(System.lineSeparator()); filter = Collections2.filter(Arrays.asList(sout), Predicates.containsPattern("Delta Record:")); if (filter.size() != 0) { break; } Thread.sleep(500); } return (filter.size() != 0); }
From source file:com.pearson.eidetic.driver.threads.RefreshAwsAccountVolumes.java
@Override public void run() { ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeNoTime; localVolumeNoTime = awsAccount_.getVolumeNoTime_Copy(); ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeTime; localVolumeTime = awsAccount_.getVolumeTime_Copy(); ConcurrentHashMap<Region, ArrayList<Volume>> localCopyVolumeSnapshots; localCopyVolumeSnapshots = awsAccount_.getCopyVolumeSnapshots_Copy(); JSONParser parser = new JSONParser(); for (Map.Entry<com.amazonaws.regions.Region, ArrayList<Volume>> entry : localVolumeNoTime.entrySet()) { com.amazonaws.regions.Region region = entry.getKey(); AmazonEC2Client ec2Client = connect(region, awsAccount_.getAwsAccessKeyId(), awsAccount_.getAwsSecretKey()); List<Volume> volumes = initialization(ec2Client, localVolumeNoTime, localVolumeTime, localCopyVolumeSnapshots, region); for (Volume volume : volumes) { JSONObject eideticParameters; eideticParameters = getEideticParameters(volume, parser); if (eideticParameters == null) { continue; }//from w w w . jav a 2s .com JSONObject createSnapshot; createSnapshot = getCreateSnapshot(volume, eideticParameters); if (createSnapshot == null) { continue; } HashMap<Integer, ConcurrentHashMap<Region, ArrayList<Volume>>> resultSet; resultSet = refreshCreateSnapshotVolumes(volume, createSnapshot, localVolumeTime, localVolumeNoTime, region); if (resultSet == null) { continue; } if (resultSet.isEmpty()) { continue; } try { localVolumeTime = resultSet.get(0); localVolumeNoTime = resultSet.get(1); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error getting from resultSet\", Volume_id=\"" + volume.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } //Time for CopyVolumeSnapshots //If this volume does not have copysnapshot localCopyVolumeSnapshots = refreshCopyVolumeSnapshots(volume, eideticParameters, localCopyVolumeSnapshots, region); } localVolumeTime = processLocalVolumeTime(localVolumeTime, region); localVolumeNoTime = processLocalVolumeNoTime(localVolumeNoTime, region); localCopyVolumeSnapshots = processLocalCopyVolumeSnapshots(localCopyVolumeSnapshots, region); ec2Client.shutdown(); } awsAccount_.replaceVolumeNoTime(localVolumeNoTime); awsAccount_.replaceVolumeTime(localVolumeTime); awsAccount_.replaceCopyVolumeSnapshots(localCopyVolumeSnapshots); }
From source file:com.firewallid.termcloud.TermCloud.java
public void saveTermCloud(JavaPairRDD<String, List<Tuple2<String, Double>>> doc, String fileNamePrefix) { doc.filter(titleFeatures -> !titleFeatures._2.isEmpty()) /* Map list to formatted line of termcloud file */ .mapToPair(titleFeatures -> new Tuple2<String, String>(titleFeatures._1, titleFeatures._2.parallelStream() .map(feature -> feature._1 + StringEscapeUtils.unescapeJava(conf.get(LINE_DELIMITER)) + feature._2) .collect(Collectors.joining(System.lineSeparator())))) /* Save to hdfs file */ .foreach(//from w w w .j a va2 s.co m titleText -> FIFile .writeStringToHDFSFile( FIFile.generateFullPath(conf.get(TERMCLOUD_FOLDER), createFileNameTermCloud(fileNamePrefix, titleText._1)), titleText._2)); }
From source file:io.cloudslang.content.utilities.actions.FindTextInPdf.java
/** * This operation checks if a text input is found in a PDF file. * * @param text The text to be searched for in the PDF file. * @param ignoreCase Whether to ignore if characters of the text are lowercase or uppercase. * Valid values: "true", "false". * Default Value: "false" * @param pathToFile The full path to the PDF file. * @param password The password for the PDF file. * @return - a map containing the output of the operation. Keys present in the map are: * returnResult - The number of occurrences of the text in the PDF file. * returnCode - the return code of the operation. 0 if the operation goes to success, -1 if the operation goes to failure. * exception - the exception message if the operation fails. *///w ww . j av a 2s .c o m @Action(name = "Find Text in PDF", description = FIND_TEXT_IN_PDF_OPERATION_DESC, outputs = { @Output(value = RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = RETURN_RESULT, description = FIND_TEXT_IN_PDF_RETURN_RESULT_DESC), @Output(value = EXCEPTION, description = EXCEPTION_DESC), }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = COMPARE_EQUAL, responseType = RESOLVED, description = SUCCESS_DESC), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = COMPARE_EQUAL, responseType = ERROR, isOnFail = true, description = FAILURE_DESC) }) public Map<String, String> execute( @Param(value = TEXT, required = true, description = INITIAL_VALUE_DESC) String text, @Param(value = IGNORE_CASE, description = IGNORE_CASE_DESC) String ignoreCase, @Param(value = PATH_TO_FILE, required = true, description = DEFAULT_VALUE_DESC) String pathToFile, @Param(value = PASSWORD, description = PASSWORD_DESC, encrypted = true) String password) { try { final Path path = Paths.get(pathToFile); final String pdfPassword = defaultIfEmpty(password, EMPTY); final String pdfContent = PdfParseService.getPdfContent(path, pdfPassword).trim() .replace(System.lineSeparator(), EMPTY); final boolean validIgnoreCase = BooleanUtilities.isValid(ignoreCase); if (!validIgnoreCase) { throw new RuntimeException( format("Invalid boolean value for ignoreCase parameter: %s", ignoreCase)); } return getSuccessResultsMap(PdfParseService.getOccurrences(pdfContent, text, toBoolean(ignoreCase))); } catch (Exception e) { return getFailureResultsMap(e); } }
From source file:org.apache.cassandra.tools.NodeTool.java
private static void printHistory(String... args) { //don't bother to print if no args passed (meaning, nodetool is just printing out the sub-commands list) if (args.length == 0) return;/*from w w w . j a v a2 s . c o m*/ String cmdLine = Joiner.on(" ").skipNulls().join(args); cmdLine = cmdLine.replaceFirst("(?<=(-pw|--password))\\s+\\S+", " <hidden>"); try (FileWriter writer = new FileWriter(new File(FBUtilities.getToolsOutputDirectory(), HISTORYFILE), true)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); writer.append(sdf.format(new Date())).append(": ").append(cmdLine).append(System.lineSeparator()); } catch (IOException | IOError ioe) { //quietly ignore any errors about not being able to write out history } }
From source file:net.certiv.json.IOProcessor.java
private void printHelp() { System.out.println("Usage:"); System.out.println("java -jar [cli_options]" + System.lineSeparator()); // etc./* w ww . ja v a 2 s . c o m*/ System.exit(0); }
From source file:com.consol.citrus.admin.process.listener.WebSocketProcessListener.java
@Override public void onProcessFail(String processId, int exitCode) { messagingTemplate.convertAndSend(TOPIC_LOG_OUTPUT, SocketEvent.createEvent(processId, SocketEvent.PROCESS_FAILED, "process failed with exit code " + exitCode + System.lineSeparator())); }
From source file:magixcel.FileMan.java
static void writeToFile() { FileOutputStream fos = null;//from w ww . j a v a2 s .co m OutputStreamWriter osw = null; BufferedWriter bw = null; String fileNameFull = OUTPUT_FILE_DIRECTORY + "output.txt"; System.out.println("writing to: " + fileNameFull); try { fos = new FileOutputStream(fileNameFull); osw = new OutputStreamWriter(fos, Charsets.ISO_8859_1); bw = new BufferedWriter(osw); for (String lineOut : OutputFormat.getOutputLines()) { if (Globals.DEVELOPER_MODE == 1) { System.out.println("Writing line: " + lineOut); } bw.write(lineOut + System.lineSeparator()); } System.out.println("DONE"); } catch (FileNotFoundException ex) { Logger.getLogger(FileMan.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FileMan.class.getName()).log(Level.SEVERE, null, ex); } finally { try { bw.close(); osw.close(); fos.close(); } catch (IOException ex) { Logger.getLogger(FileMan.class.getName()).log(Level.SEVERE, null, ex); } } }