Example usage for org.apache.commons.io IOUtils LINE_SEPARATOR_UNIX

List of usage examples for org.apache.commons.io IOUtils LINE_SEPARATOR_UNIX

Introduction

In this page you can find the example usage for org.apache.commons.io IOUtils LINE_SEPARATOR_UNIX.

Prototype

String LINE_SEPARATOR_UNIX

To view the source code for org.apache.commons.io IOUtils LINE_SEPARATOR_UNIX.

Click Source Link

Document

The Unix line separator string.

Usage

From source file:com.example.listsync.WebDavRepository.java

private void doUpload(String file, List<String> content) throws IOException {
    LOGGER.info("uploading {}", file);
    LOGGER.info("uploading {} -> {}", file, content);
    PutMethod putMethod = new PutMethod(config.getBaseUrl() + config.getWatchpath() + file);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    IOUtils.writeLines(content, IOUtils.LINE_SEPARATOR_UNIX, output);
    putMethod.setRequestEntity(new ByteArrayRequestEntity(output.toByteArray()));
    int code = client.executeMethod(putMethod);
    LOGGER.info("upload resultcode: {}", code);
}

From source file:com.webguys.djinn.marid.util.BuiltinAnnotationProcessor.java

private void saveDatabase() throws Exception {
    if (!db.exists() && !db.createNewFile()) {
        throw new Exception(String.format("Unable to create the db file: %s", DB_PATHNAME));
    }//www  .ja  v a  2 s .com

    PrintWriter writer = new PrintWriter(db, "UTF-8");
    IOUtils.writeLines(this.builtins, IOUtils.LINE_SEPARATOR_UNIX, writer);
    writer.flush();
    IOUtils.closeQuietly(writer);
}

From source file:net.sourceforge.pmd.docs.MockedFileWriter.java

public static String normalizeLineSeparators(String s) {
    return s.replaceAll(Pattern.quote(IOUtils.LINE_SEPARATOR_WINDOWS), IOUtils.LINE_SEPARATOR_UNIX)
            .replaceAll(Pattern.quote(IOUtils.LINE_SEPARATOR_UNIX), PMD.EOL);
}

From source file:net.sourceforge.pmd.renderers.YAHTMLRendererTest.java

private static String normalizeLineSeparators(String s) {
    return s.replaceAll(Pattern.quote(IOUtils.LINE_SEPARATOR_WINDOWS), IOUtils.LINE_SEPARATOR_UNIX)
            .replaceAll(Pattern.quote(IOUtils.LINE_SEPARATOR_UNIX), PMD.EOL);
}

From source file:org.apache.flume.source.TestNetcatSource.java

private void sendEvent(Socket socket, String content, String encoding) throws IOException {
    OutputStream output = socket.getOutputStream();
    IOUtils.write(content + IOUtils.LINE_SEPARATOR_UNIX, output, encoding);
    output.flush();//from   w ww  .jav a2s  .  c o m
}

From source file:org.archive.util.FileUtilsTest.java

protected void setUp() throws Exception {
    super.setUp();
    this.srcDirFile = new File(getTmpDir(), srcDirName);
    FileUtils.ensureWriteableDirectory(srcDirFile);
    this.tgtDirFile = new File(getTmpDir(), tgtDirName);
    FileUtils.ensureWriteableDirectory(tgtDirFile);
    addFiles();//from www .ja  va 2s  . c om

    zeroLengthLinesUnix = setUpLinesFile("zeroLengthLinesUnix", 0, 0, 400, IOUtils.LINE_SEPARATOR_UNIX);
    zeroLengthLinesWindows = setUpLinesFile("zeroLengthLinesUnix", 0, 0, 400, IOUtils.LINE_SEPARATOR_WINDOWS);

    smallLinesUnix = setUpLinesFile("smallLinesUnix", 0, 25, 400, IOUtils.LINE_SEPARATOR_UNIX);
    smallLinesWindows = setUpLinesFile("smallLinesWindows", 0, 25, 400, IOUtils.LINE_SEPARATOR_WINDOWS);
    largeLinesUnix = setUpLinesFile("largeLinesUnix", 128, 256, 5, IOUtils.LINE_SEPARATOR_UNIX);
    largeLinesWindows = setUpLinesFile("largeLinesWindows", 128, 256, 4096, IOUtils.LINE_SEPARATOR_WINDOWS);

    nakedLastLineUnix = setUpLinesFile("nakedLastLineUnix", 0, 50, 401, IOUtils.LINE_SEPARATOR_UNIX);
    org.apache.commons.io.FileUtils.writeStringToFile(nakedLastLineUnix, "a");
    nakedLastLineWindows = setUpLinesFile("nakedLastLineWindows", 0, 50, 401, IOUtils.LINE_SEPARATOR_WINDOWS);
    org.apache.commons.io.FileUtils.writeStringToFile(nakedLastLineWindows, "a");
}

From source file:org.jasig.maven.notice.CheckNoticeMojoTest.java

public void copyFileWithOppositeLineEnding(File src, File dst) throws IOException {
    final List<String> lines = FileUtils.readLines(src);
    if (IOUtils.LINE_SEPARATOR_UNIX.equals(IOUtils.LINE_SEPARATOR)) {
        FileUtils.writeLines(dst, lines, IOUtils.LINE_SEPARATOR_WINDOWS);
    } else {//from w  ww  .j  av  a2s  .  c o  m
        FileUtils.writeLines(dst, lines, IOUtils.LINE_SEPARATOR_UNIX);
    }
}

From source file:org.opensingular.form.io.IOUtil.java

public static void writeLines(OutputStream out, String... lines) throws IOException {
    IOUtils.writeLines(Arrays.asList(lines), IOUtils.LINE_SEPARATOR_UNIX, out, UTF8);
}

From source file:org.raml.v2.internal.framework.suggester.SuggesterTestCase.java

@Test
public void verifySuggestion() throws IOException {
    final RamlSuggester ramlSuggester = new RamlSuggester();
    String content = IOUtils.toString(new FileInputStream(input), "UTF-8");

    if (IS_OS_WINDOWS) {
        content = content.replace(IOUtils.LINE_SEPARATOR_WINDOWS, IOUtils.LINE_SEPARATOR_UNIX);
    }//  ww w.ja  v a  2  s . co  m

    final int offset = content.indexOf(CURSOR_KEYWORD);
    final String document = content.substring(0, offset) + content.substring(offset + CURSOR_KEYWORD.length());
    final List<Suggestion> suggestions = ramlSuggester.suggestions(document, offset - 1).getSuggestions();
    final ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    dump = ow.writeValueAsString(suggestions);
    expected = IOUtils.toString(new FileInputStream(this.expectedOutput));
    Assert.assertTrue(jsonEquals(dump, expected));
}

From source file:org.sonar.colorizer.CodeColorizerTest.java

/**
 * @return Reader for specified file with EOL normalized to LF.
 *//*from   ww w  .j  a va 2  s .  c  om*/
private Reader readFile(String path) throws IOException {
    return readFile(path, IOUtils.LINE_SEPARATOR_UNIX);
}