Example usage for java.lang System lineSeparator

List of usage examples for java.lang System lineSeparator

Introduction

In this page you can find the example usage for java.lang System lineSeparator.

Prototype

String lineSeparator

To view the source code for java.lang System lineSeparator.

Click Source Link

Usage

From source file:com.verigreen.collector.common.VerigreenNeededLogic.java

private VerigreenNeededLogic(String protectedBranches, String permittedUsers, String hashedPassword,
        String fullPush) throws IOException {

    VerigreenMap.put("_protectedBranches", protectedBranches);
    VerigreenMap.put("_permittedUsers", permittedUsers);
    VerigreenMap.put("_hashedPassword", hashedPassword);
    VerigreenMap.put("_fullPush", fullPush);
    getHistory();//  www  .  j  av  a 2 s.  c o  m
    setJenkinsProperties();
    //         setGitRepositoryPath();

    try {
        checkGitRepo();
    } catch (Throwable thrown) {
        VerigreenLogger.get().error(getClass().getName(), RuntimeUtils.getCurrentMethodName(),
                String.format("Repository not found: %s", properties.getProperty("git.repositoryLocation")),
                thrown);
        String lineSeparator = System.lineSeparator();
        sendEmailNotification("Attention: Repository not found",
                "Repository not found: <b>" + properties.getProperty("git.repositoryLocation") + "</b>. "
                        + thrown.getMessage() + "." + lineSeparator + "Collector name: <b>"
                        + properties.getProperty("collectors") + "</b>." + lineSeparator
                        + "Collector location: " + properties.getProperty("collector.address") + "."
                        + lineSeparator
                        + "We suggest you clone the repository from your Git provider indicated by your <b>"
                        + vgHomePath + "</b> file in the git.repositoryLocation property." + lineSeparator,
                new String[] { properties.getProperty("email.address") }, getSignature());
    }

    Thread t = new Thread(new Watchdir());
    t.start();
}

From source file:com.github.rinde.gpem17.eval.SimRuntimeLogger.java

void write() {
    lastWrite = System.currentTimeMillis();
    StringBuilder sb = new StringBuilder();
    String timestamp = ISODateTimeFormat.dateHourMinuteSecond().print(lastWrite);

    long sum = 0;
    double[] arr = new double[receivedResults.size()];
    for (int i = 0; i < receivedResults.size(); i++) {
        SimResult info = (SimResult) receivedResults.get(i).getResultObject();
        sum += info.getStats().computationTime;
        arr[i] = info.getStats().computationTime;
    }/*ww w . j ava 2 s  .  co  m*/
    double mean = sum / receivedResults.size();
    long sd = DoubleMath.roundToLong(new StandardDeviation().evaluate(arr, mean), RoundingMode.HALF_DOWN);
    long longMean = DoubleMath.roundToLong(mean, RoundingMode.HALF_DOWN);

    sb.append(timestamp).append(",").append(receivedSims).append("/").append(totalSims).append(", Received ")
            .append(receivedResults.size()).append(" results in last minute, avg comp time,")
            .append(PeriodFormat.getDefault().print(new Period(longMean))).append(", standard deviation,")
            .append(PeriodFormat.getDefault().print(new Period(sd))).append(System.lineSeparator());
    try {
        Files.append(sb.toString(), progressFile, Charsets.UTF_8);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    receivedResults.clear();
}

From source file:io.cloudslang.content.utilities.services.osdetector.NmapOsDetectorService.java

@Override
public OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs) {
    OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails();
    List<String> nmapCommandOutput = new ArrayList<>();
    try {/* w  ww.  j a  va 2  s  .c o  m*/
        int timeout = parseInt(osDetectorInputs.getNmapTimeout());

        ProcessResponseEntity responseEntity = new ProcessExecutor().execute(buildNmapCommand(osDetectorInputs),
                timeout);
        if (responseEntity.isTimeout()) {
            addTimeoutErrorMessage(nmapCommandOutput);
        } else {
            String stdOut = responseEntity.getStdout();
            String stdErrors = responseEntity.getStderr();
            int exitCode = responseEntity.getExitCode();

            if (!isEmpty(stdOut)) {
                nmapCommandOutput.add(stdOut);
                String osName = osDetectorHelperService.cropValue(stdOut, OS_DETAILS, System.lineSeparator());
                operatingSystemDetails.setName(osName);
                operatingSystemDetails.setFamily(osDetectorHelperService.resolveOsFamily(osName));
            }
            if (!isEmpty(stdErrors)) {
                nmapCommandOutput.add(stdErrors);
            }
            nmapCommandOutput.add("Execution of Nmap command had exit code: " + exitCode);
        }
    } catch (IOException e) {
        nmapCommandOutput.add("Failed to run Nmap command: " + e.getMessage());
    } catch (InterruptedException e) {
        nmapCommandOutput.add("Execution of Nmap command was canceled.");
    } catch (ExecutionException e) {
        nmapCommandOutput.add("An exception occurred while running the Nmap command: " + e.getMessage());
    } catch (TimeoutException e) {
        addTimeoutErrorMessage(nmapCommandOutput);
    }
    operatingSystemDetails.addCommandOutput(NMAP, nmapCommandOutput);
    return operatingSystemDetails;
}

From source file:com.glluch.ecf2xmlmaven.Writer.java

protected static void writePart2Solr(String path, String txt, String solrType, String id, String solrComment)
        throws IOException {

    HashMap<String, Integer> terms;
    terms = ieee.findTerms(txt);/* w w w.j  a  v  a  2  s .  c o  m*/
    if (terms.size() > 0) {
        String xml = "<add><doc>" + System.lineSeparator();
        //Mandatory params
        xml += "<field name=\"id\"";
        xml += ">";
        xml += id;

        xml += "</field>" + System.lineSeparator();
        xml += "<field name=\"type\">" + solrType;
        xml += "</field>" + System.lineSeparator();

        //terms
        xml += terms2xml("ieee_term", terms) + System.lineSeparator();
        //optional elements
        if (StringUtils.isNotEmpty(solrComment)) {

            xml += "<field name=\"comment\">" + solrComment;
            xml += "</field>" + System.lineSeparator();
        }

        //end of xml
        xml += "</doc></add>";
        //competencesXMLsolr
        String fileTitle = path + id + ".xml";
        FileUtils.writeStringToFile(new File(fileTitle), xml);
    } else {
        show(id + " has no ieee terms");
    }

}

From source file:ReportGen.java

public ReportGen(NPRInterface client, String user) throws IOException {
    initComponents();//  w ww  .  ja va 2  s  .c o m
    this.client = client;
    this.user = user;
    tablelabel1.setEnabled(false);
    residents.setEnabled(false);
    try {
        BufferedReader br = new BufferedReader(new FileReader("dir\\defaults.txt"));
        try {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
            path = sb.toString().trim();
        } catch (IOException ex) {
            //                Logger.getLogger(AdminArchiveFrame.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        } finally {
            br.close();
        }
        residents.removeAllItems();
        ArrayList<ResidentImpl> list = client.getAllResident();
        for (ResidentImpl l : list) {
            residents.addItem(l.getFullName());
        }
    } catch (RemoteException | FileNotFoundException ex) {
        //            Logger.getLogger(ReportGen.class.getName()).log(Level.SEVERE, null, ex);
        new MessageDialog().error(this, ex.getMessage());
    }
    try {
        residents.removeAllItems();
        ArrayList<ResidentImpl> list = client.getAllResident();
        for (ResidentImpl l : list) {
            residents.addItem(l.getFullName());
        }
        setContinue = true;
    } catch (RemoteException ex) {
        //            Logger.getLogger(ReportGen.class.getName()).log(Level.SEVERE, null, ex);
        new MessageDialog().error(this, ex.getMessage());
    }
    defaultPreview();
}

From source file:org.apache.apex.malhar.sql.FileEndpointTest.java

@Test
public void testApplication() throws Exception {
    File modelFile = new File("src/test/resources/model/model_file_csv.json");
    String model = FileUtils.readFileToString(modelFile);

    PrintStream originalSysout = System.out;

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    System.setOut(new PrintStream(baos));

    try {/*from   w ww  .j  ava  2s  .c  o m*/
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        lma.prepareDAG(new Application(model), conf);
        LocalMode.Controller lc = lma.getController();
        lc.runAsync();

        waitTillStdoutIsPopulated(baos, 30000);

        lc.shutdown();
    } catch (ConstraintViolationException e) {
        Assert.fail("constraint violations: " + e.getConstraintViolations());
    } catch (Exception e) {
        Assert.fail("Exception: " + e);
    }

    System.setOut(originalSysout);

    String[] sout = baos.toString().split(System.lineSeparator());
    Collection<String> filter = Collections2.filter(Arrays.asList(sout),
            Predicates.containsPattern("Delta Record:"));

    String[] actualLines = filter.toArray(new String[filter.size()]);
    Assert.assertEquals(6, actualLines.length);
    Assert.assertTrue(actualLines[0].contains("RowTime=Mon Feb 15 10:15:00 GMT 2016, Product=paint1"));
    Assert.assertTrue(actualLines[1].contains("RowTime=Mon Feb 15 10:16:00 GMT 2016, Product=paint2"));
    Assert.assertTrue(actualLines[2].contains("RowTime=Mon Feb 15 10:17:00 GMT 2016, Product=paint3"));
    Assert.assertTrue(actualLines[3].contains("RowTime=Mon Feb 15 10:18:00 GMT 2016, Product=paint4"));
    Assert.assertTrue(actualLines[4].contains("RowTime=Mon Feb 15 10:19:00 GMT 2016, Product=paint5"));
    Assert.assertTrue(actualLines[5].contains("RowTime=Mon Feb 15 10:10:00 GMT 2016, Product=abcde6"));
}

From source file:com.kotcrab.vis.editor.util.CrashReporter.java

private void println() {
    crashReport.append(System.lineSeparator());
}

From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeTime.java

@Override
public void run() {
    isFinished_ = false;/*from  w  w  w  .  jav  a 2 s  .c  o m*/
    AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_);

    for (Volume vol : VolumeTime_) {
        try {

            Date date = new java.util.Date();
            JSONParser parser = new JSONParser();

            String inttagvalue = getIntTagValue(vol);
            if (inttagvalue == null) {
                continue;
            }

            JSONObject eideticParameters;
            try {
                Object obj = parser.parse(inttagvalue);
                eideticParameters = (JSONObject) obj;
            } 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) + "\"");
                continue;
            }

            String period = getPeriod(eideticParameters, vol);
            if (period == null) {
                continue;
            }

            Integer keep = getKeep(eideticParameters, vol);
            if (keep == null) {
                continue;
            }

            Boolean success;
            success = snapshotCreation(ec2Client, vol, period, date);
            if (!success) {
                continue;
            }

            snapshotDeletion(ec2Client, vol, period, keep);

        } catch (Exception e) {
            logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                    + "\",Event=\"Error\", Error=\"error in SnapshotVolumeTime workflow\", stacktrace=\""
                    + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\"");
        }

    }
    ec2Client.shutdown();
    isFinished_ = true;
}

From source file:com.email.SendEmail.java

/**
 * Sends a single email and uses account based off of the section that the
 * email comes from after email is sent the attachments are gathered
 * together and collated into a single PDF file and a history entry is
 * created based off of that entry//w ww.  j  a  v a2s  .c  o m
 *
 * @param eml EmailOutModel
 */
public static void sendEmails(EmailOutModel eml) {
    SystemEmailModel account = null;

    String section = eml.getSection();
    if (eml.getSection().equalsIgnoreCase("Hearings") && (eml.getCaseType().equalsIgnoreCase("MED")
            || eml.getCaseType().equalsIgnoreCase("REP") || eml.getCaseType().equalsIgnoreCase("ULP"))) {
        section = eml.getCaseType();
    }

    //Get Account
    for (SystemEmailModel acc : Global.getSystemEmailParams()) {
        if (acc.getSection().equals(section)) {
            account = acc;
            break;
        }
    }

    //Account Exists?
    if (account != null) {
        //Case Location
        String casePath = (eml.getCaseType().equals("CSC") || eml.getCaseType().equals("ORG"))
                ? FileService.getCaseFolderORGCSCLocation(eml)
                : FileService.getCaseFolderLocation(eml);

        //Attachment List
        boolean allFilesExists = true;
        List<EmailOutAttachmentModel> attachmentList = EmailOutAttachment.getAttachmentsByEmail(eml.getId());

        for (EmailOutAttachmentModel attach : attachmentList) {
            File attachment = new File(casePath + attach.getFileName());
            boolean exists = attachment.exists();
            if (exists == false) {
                allFilesExists = false;
                SECExceptionsModel item = new SECExceptionsModel();
                item.setClassName("SendEmail");
                item.setMethodName("sendEmails");
                item.setExceptionType("FileMissing");
                item.setExceptionDescription("Can't Send Email, File Missing for EmailID: " + eml.getId()
                        + System.lineSeparator() + "EmailSubject: " + eml.getSubject() + System.lineSeparator()
                        + "File: " + attachment);

                ExceptionHandler.HandleNoException(item);

                break;
            } else {
                if ("docx".equalsIgnoreCase(FilenameUtils.getExtension(attach.getFileName()))
                        || "doc".equalsIgnoreCase(FilenameUtils.getExtension(attach.getFileName()))) {
                    if (!attachment.renameTo(attachment)) {
                        allFilesExists = false;
                        SECExceptionsModel item = new SECExceptionsModel();
                        item.setClassName("SendEmail");
                        item.setMethodName("sendEmails");
                        item.setExceptionType("File In Use");
                        item.setExceptionDescription("Can't Send Email, File In Use for EmailID: " + eml.getId()
                                + System.lineSeparator() + "EmailSubject: " + eml.getSubject()
                                + System.lineSeparator() + "File: " + attachment);

                        ExceptionHandler.HandleNoException(item);
                        break;
                    }
                }
            }
        }

        if (allFilesExists) {
            //Set up Initial Merge Utility
            PDFMergerUtility ut = new PDFMergerUtility();

            //List ConversionPDFs To Delete Later
            List<String> tempPDFList = new ArrayList<>();

            //create email message body
            Date emailSentTime = new Date();
            String emailPDFname = EmailBodyToPDF.createEmailOutBody(eml, attachmentList, emailSentTime);

            //Add Email Body To PDF Merge
            try {
                ut.addSource(casePath + emailPDFname);
                tempPDFList.add(casePath + emailPDFname);
            } catch (FileNotFoundException ex) {
                ExceptionHandler.Handle(ex);
            }

            //Get parts
            String FromAddress = account.getEmailAddress();
            String[] TOAddressess = ((eml.getTo() == null) ? "".split(";") : eml.getTo().split(";"));
            String[] CCAddressess = ((eml.getCc() == null) ? "".split(";") : eml.getCc().split(";"));
            String[] BCCAddressess = ((eml.getBcc() == null) ? "".split(";") : eml.getBcc().split(";"));
            String emailSubject = eml.getSubject();
            String emailBody = eml.getBody();

            //Set Email Parts
            Authenticator auth = EmailAuthenticator.setEmailAuthenticator(account);
            Properties properties = EmailProperties.setEmailOutProperties(account);
            Session session = Session.getInstance(properties, auth);
            MimeMessage smessage = new MimeMessage(session);
            Multipart multipart = new MimeMultipart();

            //Add Parts to Email Message
            try {
                smessage.addFrom(new InternetAddress[] { new InternetAddress(FromAddress) });
                for (String To : TOAddressess) {
                    if (EmailValidator.getInstance().isValid(To)) {
                        smessage.addRecipient(Message.RecipientType.TO, new InternetAddress(To));
                    }
                }
                for (String CC : CCAddressess) {
                    if (EmailValidator.getInstance().isValid(CC)) {
                        smessage.addRecipient(Message.RecipientType.CC, new InternetAddress(CC));
                    }
                }
                for (String BCC : BCCAddressess) {
                    if (EmailValidator.getInstance().isValid(BCC)) {
                        smessage.addRecipient(Message.RecipientType.BCC, new InternetAddress(BCC));
                    }
                }
                smessage.setSubject(emailSubject);

                MimeBodyPart messageBodyPart = new MimeBodyPart();
                messageBodyPart.setContent(emailBody, "text/plain");
                multipart.addBodyPart(messageBodyPart);

                //get attachments
                for (EmailOutAttachmentModel attachment : attachmentList) {
                    String fileName = attachment.getFileName();
                    String extension = FilenameUtils.getExtension(fileName);

                    //Convert attachments to PDF
                    //If Image
                    if (FileService.isImageFormat(fileName)) {
                        fileName = ImageToPDF.createPDFFromImageNoDelete(casePath, fileName);

                        //Add Attachment To PDF Merge
                        try {
                            ut.addSource(casePath + fileName);
                            tempPDFList.add(casePath + fileName);
                        } catch (FileNotFoundException ex) {
                            ExceptionHandler.Handle(ex);
                        }

                        //If Word Doc
                    } else if (extension.equals("docx") || extension.equals("doc")) {
                        fileName = WordToPDF.createPDFNoDelete(casePath, fileName);

                        //Add Attachment To PDF Merge
                        try {
                            ut.addSource(casePath + fileName);
                            tempPDFList.add(casePath + fileName);
                        } catch (FileNotFoundException ex) {
                            ExceptionHandler.Handle(ex);
                        }

                        //If Text File
                    } else if ("txt".equals(extension)) {
                        fileName = TXTtoPDF.createPDFNoDelete(casePath, fileName);

                        //Add Attachment To PDF Merge
                        try {
                            ut.addSource(casePath + fileName);
                            tempPDFList.add(casePath + fileName);
                        } catch (FileNotFoundException ex) {
                            ExceptionHandler.Handle(ex);
                        }

                        //If PDF
                    } else if (FilenameUtils.getExtension(fileName).equals("pdf")) {

                        //Add Attachment To PDF Merge
                        try {
                            ut.addSource(casePath + fileName);
                        } catch (FileNotFoundException ex) {
                            ExceptionHandler.Handle(ex);
                        }
                    }

                    DataSource source = new FileDataSource(casePath + fileName);
                    messageBodyPart = new MimeBodyPart();
                    messageBodyPart.setDataHandler(new DataHandler(source));
                    messageBodyPart.setFileName(fileName);
                    multipart.addBodyPart(messageBodyPart);
                }
                smessage.setContent(multipart);

                //Send Message
                if (Global.isOkToSendEmail()) {
                    Transport.send(smessage);
                } else {
                    Audit.addAuditEntry("Email Not Actually Sent: " + eml.getId() + " - " + emailSubject);
                }

                //DocumentFileName
                String savedDoc = (String.valueOf(new Date().getTime()) + "_" + eml.getSubject())
                        .replaceAll("[:\\\\/*?|<>]", "_") + ".pdf";

                //Set Merge File Destination
                ut.setDestinationFileName(casePath + savedDoc);

                //Try to Merge
                try {
                    ut.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
                } catch (IOException ex) {
                    ExceptionHandler.Handle(ex);
                }

                //Add emailBody Activity
                addEmailActivity(eml, savedDoc, emailSentTime);

                //Copy to related case folders
                if (section.equals("MED")) {
                    List<RelatedCaseModel> relatedMedList = RelatedCase.getRelatedCases(eml);
                    if (relatedMedList.size() > 0) {
                        for (RelatedCaseModel related : relatedMedList) {

                            //Copy finalized document to proper folder
                            File srcFile = new File(casePath + savedDoc);

                            File destPath = new File((section.equals("CSC") || section.equals("ORG"))
                                    ? FileService.getCaseFolderORGCSCLocation(related)
                                    : FileService.getCaseFolderLocationRelatedCase(related));
                            destPath.mkdirs();

                            try {
                                FileUtils.copyFileToDirectory(srcFile, destPath);
                            } catch (IOException ex) {
                                Logger.getLogger(SendEmail.class.getName()).log(Level.SEVERE, null, ex);
                            }

                            //Add Related Case Activity Entry
                            addEmailActivityRelatedCase(eml, related, savedDoc, emailSentTime);
                        }
                    }
                } else {
                    //This is blanket and should grab all related cases. (UNTESTED outside of CMDS)
                    List<EmailOutRelatedCaseModel> relatedList = EmailOutRelatedCase.getRelatedCases(eml);
                    if (relatedList.size() > 0) {
                        for (EmailOutRelatedCaseModel related : relatedList) {

                            //Copy finalized document to proper folder
                            File srcFile = new File(casePath + savedDoc);

                            File destPath = new File((section.equals("CSC") || section.equals("ORG"))
                                    ? FileService.getCaseFolderORGCSCLocation(related)
                                    : FileService.getCaseFolderLocationEmailOutRelatedCase(related));
                            destPath.mkdirs();

                            try {
                                FileUtils.copyFileToDirectory(srcFile, destPath);
                            } catch (IOException ex) {
                                Logger.getLogger(SendEmail.class.getName()).log(Level.SEVERE, null, ex);
                            }

                            //Add Related Case Activity Entry
                            addEmailOutActivityRelatedCase(eml, related, savedDoc, emailSentTime);
                        }
                    }
                }

                //Clean SQL entries
                EmailOut.deleteEmailEntry(eml.getId());
                EmailOutAttachment.deleteAttachmentsForEmail(eml.getId());
                EmailOutRelatedCase.deleteEmailOutRelatedForEmail(eml.getId());

                //Clean up temp PDFs
                for (String tempPDF : tempPDFList) {
                    new File(tempPDF).delete();
                }

            } catch (AddressException ex) {
                ExceptionHandler.Handle(ex);
            } catch (MessagingException ex) {
                ExceptionHandler.Handle(ex);
            }
        }
    }
}

From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeSync.java

@Override
public void run() {
    isFinished_ = false;/*www.  ja  v a  2 s .  c  om*/
    AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_);

    for (Volume vol : VolumeSync_) {
        try {

            Date date = new java.util.Date();
            JSONParser parser = new JSONParser();

            String inttagvalue = getIntTagValue(vol);
            if (inttagvalue == null) {
                continue;
            }

            JSONObject eideticParameters;
            try {
                Object obj = parser.parse(inttagvalue);
                eideticParameters = (JSONObject) obj;
            } catch (Exception e) {
                logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId()
                        + "\", stacktrace=\"" + e.toString() + System.lineSeparator()
                        + StackTrace.getStringFromStackTrace(e) + "\"");
                continue;
            }

            //Same
            Integer keep = getKeep(eideticParameters, vol);
            if (keep == null) {
                continue;
            }

            Boolean success;
            success = snapshotCreation(ec2Client, vol, date);
            if (!success) {
                continue;
            }

            snapshotDeletion(ec2Client, vol, keep);

        } catch (Exception e) {
            logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_
                    + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\""
                    + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\"");
        }

    }
    ec2Client.shutdown();
    isFinished_ = true;
}