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.z2data.files.WriteOperations.java

/**
 * Write error URL in file/*  w  w w.jav a 2s  . c  om*/
 * 
 * @param outputPath
 * @param URL
 * @param errorMessage
 */
public static void writeErrorData(String outputPath, String URL, String errorMessage) {
    File file = null;
    try {
        file = new File(outputPath);

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

        String errorFileName = "ERRORS_URLS_" + file.getName();
        File errorFile = null;
        if (file.getParent() == null || file.getParent().isEmpty()) {
            errorFile = new File(errorFileName);
        } else {
            errorFile = new File(file.getParent() + errorFileName);
        }

        if (!errorFile.exists()) {
            errorFile.createNewFile();
        }
        FileUtils.writeStringToFile(errorFile, URL + "\t" + errorMessage, true);
        FileUtils.writeStringToFile(errorFile, System.lineSeparator(), true);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

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

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

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

    return report;
}

From source file:nl.armatiek.xslweb.web.servlet.DelegatingServletOutputStream.java

public DelegatingServletOutputStream(OutputStream os) {
    this.os = os;
    this.lineSeparator = System.lineSeparator();
}

From source file:joachimeichborn.geotag.logging.LongLogFormat.java

@Override
public String format(final LogRecord aRecord) {
    final StringBuilder sb = new StringBuilder();
    sb.append(new DateTime(aRecord.getMillis()).toString());
    sb.append(" [").append(aRecord.getLevel().getName().charAt(0)).append("] ");
    sb.append(aRecord.getMessage());/*from www  . j a va2  s . c  om*/
    sb.append(" <").append(aRecord.getLoggerName()).append(">");
    sb.append(System.lineSeparator());
    if (aRecord.getThrown() != null) {
        sb.append(ExceptionUtils.getStackTrace(aRecord.getThrown()));
    }
    return sb.toString();
}

From source file:hoot.services.controllers.info.ErrorLog.java

static String generateExportLog() throws IOException {
    String fileId = UUID.randomUUID().toString();

    AboutResource about = new AboutResource();

    VersionInfo vInfo = about.getCoreVersionInfo();
    String data = System.lineSeparator() + "************ CORE VERSION INFO ***********"
            + System.lineSeparator();
    data += vInfo.toString();/* w w w  .j  av  a 2s  . c om*/

    CoreDetail cd = about.getCoreVersionDetail();
    data += System.lineSeparator() + "************ CORE ENVIRONMENT ***********" + System.lineSeparator();

    if (cd != null) {
        data += StringUtils.join(cd.getEnvironmentInfo(), System.lineSeparator());
    }

    data += System.lineSeparator() + "************ SERVICE VERSION INFO ***********" + System.lineSeparator();
    data += about.getServicesVersionInfo().toString();
    data += System.lineSeparator() + "************ CATALINA LOG ***********" + System.lineSeparator();

    // 5MB Max
    int maxSize = 5000000;

    String logStr = getErrorlog(maxSize);

    String outputPath = TEMP_OUTPUT_PATH + File.separator + fileId;
    try (RandomAccessFile raf = new RandomAccessFile(outputPath, "rw")) {
        raf.writeBytes(data + System.lineSeparator() + logStr);
        return outputPath;
    }
}

From source file:org.bonitasoft.web.designer.utils.assertions.JsAssert.java

/**
 * For each string lines we trim them to avoid whitespace issue when comparing strings
 */// w w  w  . j  a  v  a2s .  c  o  m
private String trimEachLines(String string) {
    String[] lines = string.split(System.lineSeparator());
    StringBuilder sb = new StringBuilder();
    for (String line : lines) {
        sb.append(StringUtils.trim(line)).append(System.lineSeparator());
    }
    return StringUtils.chop(sb.toString());
}

From source file:edu.illinois.cs.cogcomp.annotation.BasicTextAnnotationBuilder.java

/**
 * The default way to create a {@link TextAnnotation} from pre-tokenized text.
 * /* w ww.  ja va2s. c o m*/
 * @param tokenizedSentences A list of sentences, each one being a list of tokens
 * @return A {@link TextAnnotation} containing the SENTENCE and TOKENS views.
 */
public static TextAnnotation createTextAnnotationFromTokens(String corpusId, String textId,
        List<String[]> tokenizedSentences) {
    Tokenization tokenization = tokenizeTextSpan(tokenizedSentences);
    String text = "";
    for (String[] sentenceTokens : tokenizedSentences)
        text += StringUtils.join(sentenceTokens, ' ') + System.lineSeparator();

    return new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
            tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
}

From source file:io.cloudslang.lang.cli.SlangBanner.java

@Override
public String getBanner() {
    StringBuilder sb = new StringBuilder();
    try (InputStream in = ClassLoader.getSystemResourceAsStream(BANNER)) {
        sb.append(IOUtils.toString(in));
    } catch (IOException e) {
        sb.append("CloudSlang");
    }/*from  w ww .ja  va  2s .c o  m*/
    sb.append(System.lineSeparator());
    sb.append(getVersion());
    return sb.toString();
}

From source file:io.github.binout.jaxrs.csv.CsvSchemaFactoryTest.java

static String inputStreamToString(InputStream is) throws IOException {
    try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
        return br.lines().collect(Collectors.joining(System.lineSeparator()));
    }//from  w w  w  .  j ava  2 s.c  o  m
}

From source file:minij.assembler.Assembler.java

public static void assemble(Configuration config, String assembly) throws AssemblerException {

    try {/*  w w  w.  j ava2 s . co  m*/
        new File(FilenameUtils.getPath(config.outputFile)).mkdirs();

        // -xc specifies the input language as C and is required for GCC to read from stdin
        ProcessBuilder processBuilder = new ProcessBuilder("gcc", "-o", config.outputFile, "-m32", "-xc",
                MiniJCompiler.RUNTIME_DIRECTORY.toString() + File.separator + "runtime_32.c", "-m32",
                "-xassembler", "-");
        Process gccCall = processBuilder.start();
        // Write C code to stdin of C Compiler
        OutputStream stdin = gccCall.getOutputStream();
        stdin.write(assembly.getBytes());
        stdin.close();

        gccCall.waitFor();

        // Print error messages of GCC
        if (gccCall.exitValue() != 0) {

            StringBuilder errOutput = new StringBuilder();
            InputStream stderr = gccCall.getErrorStream();
            String line;
            BufferedReader bufferedStderr = new BufferedReader(new InputStreamReader(stderr));
            while ((line = bufferedStderr.readLine()) != null) {
                errOutput.append(line + System.lineSeparator());
            }
            bufferedStderr.close();
            stderr.close();

            throw new AssemblerException(
                    "Failed to compile assembly:" + System.lineSeparator() + errOutput.toString());
        }

        Logger.logVerbosely("Successfully compiled assembly");
    } catch (IOException e) {
        throw new AssemblerException("Failed to transfer assembly to gcc", e);
    } catch (InterruptedException e) {
        throw new AssemblerException("Failed to invoke gcc", e);
    }

}