Example usage for org.apache.commons.io FileUtils readLines

List of usage examples for org.apache.commons.io FileUtils readLines

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils readLines.

Prototype

public static List readLines(File file) throws IOException 

Source Link

Document

Reads the contents of a file line by line to a List of Strings using the default encoding for the VM.

Usage

From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.checkers.OrientDbSwitchSetChecker.java

@Override
public Collection<OrientDbSwitchSetMatch> check() throws IOException {

    final Collection<OrientDbSwitchSetMatch> matches = new ArrayList<OrientDbSwitchSetMatch>();
    List<String> lines = FileUtils.readLines(FileUtils.getFile(queryPath + "SwitchSet.gremlin"));
    List<Row> result = driver.runQuery(lines);

    for (Row row : result) {
        matches.add(new OrientDbSwitchSetMatch(row));
    }/* www .  j  a va  2s .  c o  m*/

    return matches;
}

From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.checkers.OrientDbRouteSensorChecker.java

@Override
public Collection<OrientDbRouteSensorMatch> check() throws IOException {

    final Collection<OrientDbRouteSensorMatch> matches = new ArrayList<OrientDbRouteSensorMatch>();
    List<String> lines = FileUtils.readLines(FileUtils.getFile(queryPath + "RouteSensor.gremlin"));
    List<Row> result = driver.runQuery(lines);

    for (Row row : result) {
        matches.add(new OrientDbRouteSensorMatch(row));
    }//from   ww w  . java 2  s.  com

    return matches;
}

From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.checkers.OrientDbSwitchSensorChecker.java

@Override
public Collection<OrientDbSwitchSensorMatch> check() throws IOException {

    final Collection<OrientDbSwitchSensorMatch> matches = new ArrayList<OrientDbSwitchSensorMatch>();
    List<String> lines = FileUtils.readLines(FileUtils.getFile(queryPath + "SwitchSensor.gremlin"));
    List<Row> result = driver.runQuery(lines);

    for (Row row : result) {
        matches.add(new OrientDbSwitchSensorMatch(row));
    }/*from   w  w  w.j a v a2s .c o  m*/

    return matches;
}

From source file:com.machinelinking.cli.exporterTest.java

@Test
public void testRun() throws IOException {
    final File in = new File("src/test/resources/dumps/enwiki-latest-pages-articles-p1.xml.gz");
    final File out = File.createTempFile("csv-exporter", ".csv");
    final int exitCode = new exporter()
            .run(String.format("--prefix http://en.wikipedia.org --in %s --out %s --threads 1",
                    in.getAbsolutePath(), out.getAbsolutePath()).split(" "));

    Assert.assertEquals(exitCode, 0);/*from  w ww  . j ava  2 s  . co  m*/
    Assert.assertEquals(FileUtils.readLines(out).size(), 11761);
}

From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.checkers.OrientDbConnectedSegmentsChecker.java

@Override
public Collection<OrientDbConnectedSegmentsMatch> check() throws IOException {

    final Collection<OrientDbConnectedSegmentsMatch> matches = new ArrayList<OrientDbConnectedSegmentsMatch>();
    List<String> lines = FileUtils.readLines(FileUtils.getFile(queryPath + "ConnectedSegments.gremlin"));
    List<Row> result = driver.runQuery(lines);

    for (Row row : result) {
        matches.add(new OrientDbConnectedSegmentsMatch(row));
    }/*from   w  w  w  .j  av  a 2 s  .c o  m*/

    return matches;
}

From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.checkers.OrientDbSemaphoreNeighborChecker.java

@Override
public Collection<OrientDbSemaphoreNeighborMatch> check() throws IOException {

    final Collection<OrientDbSemaphoreNeighborMatch> matches = new ArrayList<OrientDbSemaphoreNeighborMatch>();
    List<String> lines = FileUtils.readLines(FileUtils.getFile(queryPath + "SemaphoreNeighbor.gremlin"));
    List<Row> result = driver.runQuery(lines);

    for (Row row : result) {
        matches.add(new OrientDbSemaphoreNeighborMatch(row));
    }//from   www. j  av  a  2 s .c  om

    return matches;
}

From source file:com.genericworkflownodes.knime.nodegeneration.model.meta.ContributingPluginMeta.java

public static ContributingPluginMeta create(Directory contributingPluginDirectory) {
    try {//from   ww  w . ja  v a 2  s.c  o m
        PluginDirectory pluginDirectory = new PluginDirectory(contributingPluginDirectory);

        List<String> lines = FileUtils.readLines(pluginDirectory.getManifestMf());

        String bundleVersion = null;
        String bundleSymbolicName = null;

        for (String line : lines) {
            if (bundleVersion == null) {
                Matcher matcherBundleVersion = patternBundleVersion.matcher(line);
                if (matcherBundleVersion.matches()) {
                    bundleVersion = matcherBundleVersion.group(1);
                }
            }
            if (bundleSymbolicName == null) {
                Matcher matcherBundleSymbolicName = patternBundleSymbolicName.matcher(line);
                if (matcherBundleSymbolicName.matches()) {
                    bundleSymbolicName = matcherBundleSymbolicName.group(1);
                }
            }
        }

        if (bundleVersion != null && bundleSymbolicName != null) {
            return new ContributingPluginMeta(bundleSymbolicName, bundleVersion, contributingPluginDirectory);
        }

    } catch (PathnameIsNoDirectoryException e) {
        LOGGER.log(Level.SEVERE,
                "Should never occur. Using the filter we guarantee that the given directory is a directory");
        LOGGER.log(Level.SEVERE, e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
    }

    throw new InvalidPluginException(contributingPluginDirectory);
}

From source file:com.gu.management.manifest.ApplicationFileProvider.java

public List<String> getFileContents(String relativePath) {
    File file = getFile(relativePath);

    if (!file.exists()) {
        LOG.error("Could not find the application file '" + file.getAbsolutePath() + "'");
        return null;
    }// ww  w. j av a2  s  .  c o m

    try {
        //noinspection unchecked
        return (List<String>) FileUtils.readLines(file);
    } catch (IOException e) {
        throw new RuntimeException("Error reading application file", e);
    }
}

From source file:gov.nih.nci.caarray.magetab.splitter.SdrfSplitterTest.java

@Before
@SuppressWarnings("unchecked")
public void setUp() throws IOException {
    sdrf = MageTabDataFiles.SPECIFICATION_EXAMPLE_SDRF;
    dataFile1 = new JavaIOFileRef(MageTabDataFiles.SPECIFICATION_EXAMPLE_DATA_FILE_1);
    dataFile2 = new JavaIOFileRef(MageTabDataFiles.SPECIFICATION_EXAMPLE_DATA_FILE_2);
    sdrfLines = FileUtils.readLines(sdrf);
    dataFile1References = 0;/* w w  w . j  av a2 s. c o  m*/
    for (String curLine : sdrfLines) {
        if (curLine.contains(dataFile1.getName())) {
            dataFile1References++;
        }
    }
}

From source file:com.redhat.red.offliner.alist.PlaintextArtifactListReader.java

@Override
public ArtifactList readPaths(final File file) throws IOException {
    List<String> paths = new ArrayList<>();
    Map<String, String> checksums = new HashMap<String, String>();
    List<String> contents = FileUtils.readLines(file);

    if (null == contents || contents.isEmpty()) {
        return null;
    }/*from ww w  .  ja  va2  s .  co m*/

    for (String c : contents) {
        c = c.trim();
        if (c.startsWith("#") || c.startsWith("//") || c.startsWith(";")) {
            //common comment types.
            continue;
        }

        // handle potential for spaces around the comma.
        String[] cArr = c.split("\\s*,\\s*");
        if (cArr.length == 0) {
            continue;
        } else if (cArr.length == 1) {
            paths.add(cArr[0]);
        } else {
            paths.add(cArr[1]);
            checksums.put(cArr[1], cArr[0]);
        }
    }

    ArtifactList result = new ArtifactList(paths, Collections.emptyList(), checksums);
    return result;
}