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

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

Introduction

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

Prototype

String LINE_SEPARATOR

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

Click Source Link

Document

The system line separator string.

Usage

From source file:org.opencastproject.composer.impl.VideoConcaternationTest.java

/**
 * Test method for/*from   w w  w .  java  2  s  . c  o m*/
 * {@link org.opencastproject.composer.impl.ComposerServiceImpl#convertImage(org.opencastproject.mediapackage.Attachment, String)}
 */
@Test
@Ignore
public void testConcat() throws Exception {
    if (!ffmpegInstalled)
        return;
    String videoName1 = "video.mp4";
    String videoName2 = "av.mov";
    URL sourceVideo1Url = getClass().getResource("/" + videoName1);
    URL sourceVideo2Url = getClass().getResource("/" + videoName2);
    File sourceVideo1 = new File(workingDirectory, videoName1);
    File sourceVideo2 = new File(workingDirectory, videoName2);
    File sourceTextFile = new File(workingDirectory, "filesToConcat.txt");
    FileUtils.copyURLToFile(sourceVideo1Url, sourceVideo1);
    FileUtils.copyURLToFile(sourceVideo2Url, sourceVideo2);

    StringBuilder sb = new StringBuilder();
    sb.append("file '").append(sourceVideo1.getAbsolutePath()).append("'").append(IOUtils.LINE_SEPARATOR);
    sb.append("file '").append(sourceVideo2.getAbsolutePath()).append("'").append(IOUtils.LINE_SEPARATOR);
    FileUtils.writeStringToFile(sourceTextFile, sb.toString());

    EncodingProfile imageConversionProfile = profiles.get("concat");
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("videoListFile", FilenameUtils.normalize(sourceTextFile.getAbsolutePath()));
    File concatenedVideo = engine.encode(sourceVideo1, imageConversionProfile, properties).get();

    // These are weak assertions, but anything else would require either integration with another 3rd party tool
    // or manual parsing of ffmpeg output. Instead, we keep this test generic (but weak).
    assertTrue(concatenedVideo.exists());
    assertTrue(concatenedVideo.length() > 0);

}

From source file:org.openengsb.persistence.rulebase.filebackend.GlobalDeclarationPersistenceBackendService.java

private void writeStorageFile(Map<String, String> globals) throws PersistenceException {
    LOGGER.debug("write globals to \"{}\"", storageFile);
    OutputStream os = null;/*from w  w w .  j a v  a2 s.c  o m*/
    try {
        os = FileUtils.openOutputStream(storageFile);
        for (Entry<String, String> entry : globals.entrySet()) {
            IOUtils.write(entry.getValue() + SEPARATOR + entry.getKey() + IOUtils.LINE_SEPARATOR, os);
        }
    } catch (IOException ex) {
        throw new PersistenceException(ex);
    } finally {
        IOUtils.closeQuietly(os);
    }
}

From source file:org.opensha.commons.data.function.EvenlyDiscretizedFunc.java

/**
 * Standard java function, usually used for debugging, prints out
 * the state of the list, such as number of points, the value of each point, etc.
 * @return/*from  ww  w  . ja  va2 s  .com*/
 */
public String toString() {
    // @formatter:off
    StringBuffer b = new StringBuffer().append("     Name: ").append(getName()).append(IOUtils.LINE_SEPARATOR)
            .append("   Points: ").append(size()).append(IOUtils.LINE_SEPARATOR).append("     Info: ")
            .append(getInfo()).append(IOUtils.LINE_SEPARATOR).append(IOUtils.LINE_SEPARATOR)
            .append("Data[x,y]:").append(IOUtils.LINE_SEPARATOR).append(getMetadataString())
            .append(IOUtils.LINE_SEPARATOR);
    return b.toString();
    // @formatter:on
}

From source file:org.opensha.commons.geo.LocationList.java

@Override
public String toString() {
    // @formatter:off
    StringBuffer b = new StringBuffer().append("List size: ").append(size()).append(IOUtils.LINE_SEPARATOR)
            .append("Locations: ");
    for (Location loc : this) {
        b.append(loc).append(IOUtils.LINE_SEPARATOR).append("           ");
    }/* w ww.j  a va 2s. c  o  m*/
    return b.toString();
    // @formatter:on
}

From source file:org.opensha.sha.faultSurface.FaultTrace.java

@Override
public String toString() {
    // @formatter:off
    StringBuffer b = new StringBuffer().append("Fault Trace: ").append(faultName).append(IOUtils.LINE_SEPARATOR)
            .append("       size: ").append(size()).append(IOUtils.LINE_SEPARATOR).append("Locations: ");
    for (Location loc : this) {
        b.append(loc).append(IOUtils.LINE_SEPARATOR).append("           ");
    }/*from   ww w.  j a  va 2s . c o m*/
    return b.toString();
    // @formatter:on
}

From source file:org.rhq.maven.plugins.ExecCliCommandMojo.java

@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
    Process process = null;//from  w  w w . j a  v  a2s . c  om
    try {
        File rhqCliStartScriptFile = getRhqCliStartScriptFile();
        // Run the CLI in forked process
        ProcessBuilder processBuilder = new ProcessBuilder() //
                .directory(rhqCliStartScriptFile.getParentFile()) // bin directory
                .command(buildRhqCliCommand(rhqCliStartScriptFile));
        getLog().info("Executing RHQ CLI command: " + IOUtils.LINE_SEPARATOR + command);
        process = processBuilder.start();
        redirectOuput(process);
        int exitCode = process.waitFor();
        if (exitCode != 0) {
            handleFailure("CLI stopped with status code: " + exitCode);
        }
    } catch (Exception e) {
        handleException(e);
    } finally {
        if (process != null) {
            process.destroy();
        }
    }
}

From source file:org.rhq.maven.plugins.ExecCliScriptMojo.java

@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
    Process process = null;/*from ww w. j  a  va2s  .  com*/
    try {
        File rhqCliStartScriptFile = getRhqCliStartScriptFile();
        // Run the CLI in forked process
        ProcessBuilder processBuilder = new ProcessBuilder() //
                .directory(rhqCliStartScriptFile.getParentFile()) // bin directory
                .command(buildRhqCliCommand(rhqCliStartScriptFile));
        getLog().info(
                "Executing RHQ CLI script file: " + IOUtils.LINE_SEPARATOR + scriptFile.getAbsolutePath());
        process = processBuilder.start();
        redirectOuput(process);
        int exitCode = process.waitFor();
        if (exitCode != 0) {
            handleFailure("CLI stopped with status code: " + exitCode);
        }
    } catch (Exception e) {
        handleException(e);
    } finally {
        if (process != null) {
            process.destroy();
        }
    }
}

From source file:org.sonar.dev.TrimMojo.java

private void trimDirectory() throws MojoExecutionException {
    File[] files = scanFiles();/*from www.j  a va 2  s  .  c  om*/
    for (File file : files) {
        StringBuilder sb = new StringBuilder();
        try {
            LineIterator lines = FileUtils.lineIterator(file, sourceEncoding);
            while (lines.hasNext()) {
                String line = lines.nextLine();
                if (line != null && !"".equals(line.trim())) {
                    sb.append(line.trim());
                    sb.append(IOUtils.LINE_SEPARATOR);
                }
            }
            FileUtils.writeStringToFile(file, sb.toString(), sourceEncoding);

        } catch (IOException e) {
            throw new MojoExecutionException("Can not trim the file " + file, e);
        }
    }
    getLog().info("Trimmed files: " + files.length);
}

From source file:org.sonar.oracleforms.plsql.decorators.CommentPathDecorator.java

public String decorate(Node node, String text) {
    if (node.isGuiItem() && StringUtils.isNotBlank(text)) {
        return new StringBuilder().append("-- path: ").append(node.getKey()).append(" (").append(node.getType())
                .append(")").append(IOUtils.LINE_SEPARATOR).append(text).toString();
    }/*from   w  w w  .  ja va 2s.  c om*/
    return text;
}

From source file:org.sonar.oracleforms.plsql.decorators.GuiBlockDecorator.java

public String decorate(Node node, String text) {
    if (!node.isGuiBlock()) {
        return text;
    }//from   ww  w.  ja v  a2s .  c om

    StringBuilder childrenBuilder = new StringBuilder();
    for (Node child : node.getChildren()) {
        if (child.isGui()) {
            String childPlsql = DecoratorFactory.decorate(child);
            if (StringUtils.isNotBlank(childPlsql)) {
                childrenBuilder.append(childPlsql).append(IOUtils.LINE_SEPARATOR);
            }
        }
    }

    if (StringUtils.isBlank(childrenBuilder.toString())) {
        return text;
    }
    return new StringBuilder().append("Declare").append(IOUtils.LINE_SEPARATOR).append("Procedure ")
            .append(node.getPlsqlName()).append("_").append(" Is").append(IOUtils.LINE_SEPARATOR)
            .append("Begin").append(IOUtils.LINE_SEPARATOR).append(childrenBuilder).append("End ")
            .append(node.getPlsqlName()).append("_").append(";").append(IOUtils.LINE_SEPARATOR).append("Begin")
            .append(IOUtils.LINE_SEPARATOR).append(node.getPlsqlName()).append("_").append(";")
            .append(IOUtils.LINE_SEPARATOR).append("End;").append(IOUtils.LINE_SEPARATOR).toString();
}