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:Main.java

public static <T> String toString(List<T> values) {
    StringBuilder buffer = new StringBuilder();
    for (T value : values) {
        buffer.append(value).append(System.lineSeparator());
    }/*w  w w.j ava2s.  c o  m*/
    return buffer.toString();
}

From source file:com.z2data.files.WriteOperations.java

/**
 * Write status Data for URL To file/*from  ww w .j a  v a  2s .  com*/
 * 
 * @param outputPath
 * @param urlData
 */
@SuppressWarnings("deprecation")
public static void writeURLData(String outputPath, URLData urlData) {

    try {
        File file = new File(outputPath);

        if (!file.exists()) {
            file.createNewFile();
        }

        FileUtils.writeStringToFile(file, urlData.getParentURL() + "\t" + urlData.getAnchorTitle() + "\t"
                + urlData.getAnchor() + "\t" + urlData.getDownloadStatus() + "\t" + urlData.getDownloadPath(),
                true);
        FileUtils.writeStringToFile(file, System.lineSeparator(), true);

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:io.hawkcd.agent.utilities.ReportAppender.java

public static StringBuilder appendStartedMessage(String message, StringBuilder report, Class classType) {
    message = MessageConstants.CONSOLE_YELLOW + message;
    report.append(message).append(System.lineSeparator());
    String line;//from  w w  w  . j  a  v a2s  . com
    if (classType == Job.class) {
        line = MessageConstants.CONSOLE_WHITE + MessageConstants.CONSOLE_THICK_LINE;
    } else {
        line = MessageConstants.CONSOLE_WHITE + MessageConstants.CONSOLE_THIN_LINE;
    }

    report.append(line).append(System.lineSeparator());

    return report;
}

From source file:org.apache.metron.common.utils.StringUtils.java

/**
 * Strips specified number of lines from beginning for String val
 * @param val//from   w ww . j  av  a 2 s.c o  m
 * @param numLines
 */
public static String stripLines(String val, int numLines) {
    int start = org.apache.commons.lang3.StringUtils.ordinalIndexOf(val, System.lineSeparator(), numLines);
    start = start >= 0 ? start : 0;
    return val.substring(start);
}

From source file:at.ac.tuwien.dsg.cloudlyra.utils.IOUtils.java

public static String readData(String fileName) {

    String tomcatTempFolder = System.getProperty("java.io.tmpdir");
    //String tomcatTempFolder="/Volumes/DATA/BigData";
    fileName = tomcatTempFolder + "/" + fileName;
    String data = "";
    try {//  w w  w.  j  a  v a2 s .  co  m
        BufferedReader 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();
        }
        data = sb.toString();
        br.close();
    } catch (Exception e) {

    }
    return data;
}

From source file:com.epam.dlab.Help.java

/** Print help to console.
 * @param resourceName the name of resource.
 * @param substitute - map for substitution in help content.
 * @throws InitializationException/*from   w w w.jav a 2  s .  c  om*/
 */
private static void printHelp(String resourceName, Map<String, String> substitute)
        throws InitializationException {
    List<String> list = BillingUtils
            .getResourceAsList("/" + Help.class.getName() + "." + resourceName + ".txt");
    String help = StringUtils.join(list, System.lineSeparator());

    if (substitute == null) {
        substitute = new HashMap<>();
    }
    substitute.put("classname", BillingScheduler.class.getName());

    for (String key : substitute.keySet()) {
        help = StringUtils.replace(help, "${" + key.toUpperCase() + "}", substitute.get(key));
    }
    System.out.println(help);
}

From source file:io.hawkcd.agent.utilities.ReportAppender.java

public static StringBuilder appendCompletedMessage(String message, StringBuilder report, JobStatus status) {
    if (status == JobStatus.PASSED) {
        message = MessageConstants.CONSOLE_GREEN + message;
    } else {//from w w  w . ja  v  a2  s .  c om
        message = MessageConstants.CONSOLE_RED + message;
    }

    report.append(message).append(System.lineSeparator());

    return report;
}

From source file:com.memtrip.gear2nd.parser.Deserialization.java

private static String readFile(Path path) {
    try {//from   ww  w .  j a v  a  2  s .  c  om
        StringBuilder sb = new StringBuilder();

        Files.lines(path).forEach(line -> {
            sb.append(line);
            sb.append(System.lineSeparator());
        });

        return sb.toString();
    } catch (IOException e) {
        return null;
    }
}

From source file:energy.usef.core.workflow.util.WorkflowUtil.java

/**
 * Validate the context based on all Enum values.
 * //from w  w w.  jav  a  2 s . com
 * @param name - The name of the Workflow Step we are currently in.
 * @param context - The {@link WorkflowContext} to validate.
 * @param values - The required enum keys.
 */
public static void validateContext(String name, WorkflowContext context,
        @SuppressWarnings("rawtypes") Enum[] values) {
    List<String> nullProperties = new ArrayList<>();
    for (@SuppressWarnings("rawtypes")
    Enum value : values) {
        String requiredProperty = value.name();
        if (context.getValue(requiredProperty) == null) {
            nullProperties.add(requiredProperty);
        }
    }
    if (!nullProperties.isEmpty()) {
        StringBuilder message = new StringBuilder("WorkflowContext validation failed for ");
        message.append(name);
        message.append(System.lineSeparator());
        message.append("The following propeties are missing: ");
        message.append(StringUtils.join(nullProperties, ", "));
        throw new WorkflowException(message.toString());
    }
}

From source file:de.micromata.genome.util.strings.ReducedMultiLineStyle.java

/**
 * Instantiates a new reduced multi line style.
 *//*from  w  ww  .j a v  a2s  .  com*/
public ReducedMultiLineStyle() {
    super();
    this.setContentStart("[");
    this.setFieldSeparator(System.lineSeparator() + "  ");
    this.setFieldSeparatorAtStart(true);
    this.setContentEnd(System.lineSeparator() + "]");
    this.setUseShortClassName(true);
}