List of usage examples for org.apache.commons.io FileUtils readLines
public static List readLines(File file) throws IOException
From source file:eu.delving.sip.TestLuceneSpatial.java
@Test public void validateList() throws IOException { URL url = getClass().getResource("/geo/latlong.txt"); List<String> lines = FileUtils.readLines(new File(url.getFile())); for (String latlong : lines) { try {// w ww . j a va 2 s . c om DistanceUtils.parseLatitudeLongitude(latlong); } catch (InvalidGeoException e) { Assert.assertEquals("Unexpected exception", "624.3020535333326,76.0872380450499", latlong); } } }
From source file:com.sangupta.shire.config.YmlConfigReader.java
@Override protected Properties readFile(File configFile) throws IOException { // read all lines List<String> lines = FileUtils.readLines(configFile); // read and return the lines return readLines(lines); }
From source file:com.gargoylesoftware.htmlunit.runners.TestCaseCorrector.java
static void correct(final FrameworkMethod method, final boolean realBrowser, final BrowserVersion browserVersion, final boolean notYetImplemented, final Throwable t) throws IOException { final String testRoot = "src/test/java/"; final String browserString = browserVersion.getNickname().toUpperCase(Locale.ROOT); final File file = new File(testRoot + method.getDeclaringClass().getName().replace('.', '/') + ".java"); final List<String> lines = FileUtils.readLines(file); final String methodLine = " public void " + method.getName() + "()"; if (realBrowser) { String defaultExpectation = null; for (int i = 0; i < lines.size(); i++) { if (" @Default".equals(lines.get(i))) { defaultExpectation = getDefaultExpectation(lines, i); }/*from www .jav a 2s . c o m*/ if (lines.get(i).startsWith(methodLine)) { i = addExpectation(lines, i, browserString, (ComparisonFailure) t); break; } if (i == lines.size() - 2) { addMethodWithExpectation(lines, i, browserString, method.getName(), (ComparisonFailure) t, defaultExpectation); break; } } } else if (!notYetImplemented) { String defaultExpectation = null; for (int i = 0; i < lines.size(); i++) { if (" @Default".equals(lines.get(i))) { defaultExpectation = getDefaultExpectation(lines, i); } if (lines.get(i).startsWith(methodLine)) { addNotYetImplemented(lines, i, browserString); break; } if (i == lines.size() - 2) { addNotYetImplementedMethod(lines, i, browserString, method.getName(), defaultExpectation); break; } } } else { for (int i = 0; i < lines.size(); i++) { if (lines.get(i).startsWith(methodLine)) { removeNotYetImplemented(lines, i, browserString); break; } } } FileUtils.writeLines(file, lines); }
From source file:ch.unibas.fittingwizard.application.xyz.ZxyGenerator.java
private void readLinesFromFile(File coordinateFile) { try {//from ww w. ja v a 2 s . co m content = FileUtils.readLines(coordinateFile); } catch (IOException e) { throw new RuntimeException("Could not read coordinates file."); } }
From source file:RdfDataGenerationApplication.java
public RdfDataGenerationApplication(String web_sites_config_file, String database_config_file, PrintWriter out) throws Exception { this.out = out; this.database_config_file = database_config_file; // process web sites: List<String> lines = (List<String>) FileUtils.readLines(new File(web_sites_config_file)); for (String line : lines) { Scanner scanner = new Scanner(line); scanner.useDelimiter(" "); try {/* www.ja v a 2 s. co m*/ String starting_url = scanner.next(); int spider_depth = Integer.parseInt(scanner.next()); spider(starting_url, spider_depth); } catch (Exception ex) { ex.printStackTrace(); } } // after processing all 4 data sources, add more RDF statements for inter-source properties: process_interpage_shared_properties(); out.close(); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.significance.OutcomeSuccessMapReaderSequenceTokenCSVImpl.java
@Override public SortedMap<String, Boolean> readOutcomeSuccessMap(File file) { SortedMap<String, Boolean> result = new TreeMap<>(); List<String> lines; try {/*from w w w .ja v a2 s . c om*/ lines = FileUtils.readLines(file); } catch (IOException e) { throw new RuntimeException(e); } // first line is comment for (int i = 1; i < lines.size(); i++) { String line = lines.get(i); String[] split = line.split(","); String token = split[2]; String key = i + "_" + token; boolean res = split[0].equals(split[1]); result.put(key, res); } return result; }
From source file:ch.unibas.fittingwizard.application.xyz.XyzFileParser.java
private void readLinesFromFile() { logger.info("Reading lines from file."); try {// ww w. j a va 2 s. com content = FileUtils.readLines(file); } catch (IOException e) { throw new RuntimeException("Could not read coordinates file."); } }
From source file:br.com.involves.converter.ConverterTest.java
@Test public void testConverterToJson() throws IllegalArgumentException, IllegalAccessException, IOException { JsonConverter converter = new JsonConverter(); File expected = new File("src/test/resources/personExpected.json"); File output = folder.newFile("personOutput.json"); Address address1 = new Address("Rua Jos", "39", "So Jos"); List<Address> listAddress = new ArrayList<>(); listAddress.add(address1);//from ww w. j a v a2 s . co m Person person = new Person("Fernando", 28, 'M', listAddress, new double[] { 8.0, 6.0, 10.0 }); converter.convert(person, output); Assert.assertTrue(output.exists()); Assert.assertEquals(FileUtils.readLines(expected), FileUtils.readLines(output)); }
From source file:de.tudarmstadt.ukp.dkpro.tc.ml.modelpersist.ModelPersistUtil.java
public static List<Object> initParameters(File tcModelLocation) throws IOException { List<Object> parameters = new ArrayList<>(); for (String parameter : FileUtils.readLines(new File(tcModelLocation, MODEL_PARAMETERS))) { if (!parameter.startsWith("#")) { String[] parts = parameter.split("="); parameters.add(parts[0]);//from w ww. j av a 2 s . co m if (isExistingFilePath(tcModelLocation, parts[1])) { parameters.add(tcModelLocation + "/" + parts[1]); } else { parameters.add(parts[1]); } } } return parameters; }
From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.checkers.OrientDbPosLengthChecker.java
@Override public Collection<OrientDbPosLengthMatch> check() throws IOException { final Collection<OrientDbPosLengthMatch> matches = new ArrayList<OrientDbPosLengthMatch>(); List<String> lines = FileUtils.readLines(FileUtils.getFile(queryPath + "PosLength.gremlin")); List<Row> result = driver.runQuery(lines); for (Row row : result) { matches.add(new OrientDbPosLengthMatch(row)); }/*from ww w. j a v a2s.co m*/ return matches; }