List of usage examples for org.apache.commons.io FileUtils readLines
public static List readLines(File file) throws IOException
From source file:com.legstar.jaxb.gen.JaxbGenModel.java
/** * Creates an external binding customization file ready for JAXB. * <p/>/* w ww .j av a2 s .c om*/ * This external binding file has less capabilities than the alternative * which is to inject annotations inline in the XML schema but has the * advantage of not messing up with the original XML schema. * * @param targetFile the xjb file that must be created * @throws CodeGenMakeException if generation fails */ public void generateXjb(final File targetFile) throws CodeGenMakeException { try { CodeGenUtil.initVelocity(); CodeGenHelper helper = new CodeGenHelper(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("helper", helper); CodeGenUtil.processTemplate(XJB_GENERATOR_NAME, XJB_TEMPLATE, "xjbModel", this, parameters, targetFile, XJB_CHARSET); if (_log.isDebugEnabled()) { _log.debug("External Bindings file:" + targetFile); for (Object line : FileUtils.readLines(targetFile)) { _log.debug(line); } } } catch (CodeGenVelocityException e) { throw new CodeGenMakeException(e); } catch (IOException e) { throw new CodeGenMakeException(e); } }
From source file:com.bitplan.pdfindex.TestPdfindexer.java
/** * test BITPlan internal usage of Pdfindexer for CPSA-F * visit http://www.bitplan.com if you are interested in the CPSA-F Software architecture course *///from w w w .j a v a 2s. co m // Ignore this test on the OpenSource version @Ignore public void testBITPlan() throws IOException { String base = "/Volumes/bitplan/Projekte/2009/CPSAMaterial2009/"; String paths[] = { "Folien/pdf", "english/Folien/pdf" }; String langs[] = { "Deutsch", "English" }; int index = 0; for (String path : paths) { String lang = langs[index++]; String htmlOutputFileName = "/tmp/cpsa-f_" + lang + ".html"; String[] args = { "--sourceFileList", base + path + "/pdffiles.lst", "--outputfile", htmlOutputFileName, "--searchKeyWordList", base + path + "/searchwords.txt", "--root", base + path + "/", "--idxfile", base + path + "/index", "--title", "CPSA-F " + lang }; this.testPdfIndexer(args); List<String> lines = FileUtils.readLines(new File(htmlOutputFileName)); showLines(lines); } }
From source file:es.uvigo.ei.sing.adops.operations.running.tcoffee.TCoffeeDefaultProcessManager.java
public SequenceDiversity calculateMinDiversity(Set<SequenceDiversity> usedSequences, File file) throws OperationException { final SortedSet<SequenceDiversity> sequences = new TreeSet<>(); try {/* w w w . j a va 2 s .c o m*/ for (String line : FileUtils.readLines(file)) { if (line.contains("AVG")) { sequences.add(new SequenceDiversity(line)); } } } catch (IOException e) { throw new OperationException(null, "Error reading diversity file", e); } for (SequenceDiversity sequence : sequences) { if (!usedSequences.contains(sequence)) { return sequence; } } return null; }
From source file:ch.unibas.fittingwizard.infrastructure.RealVmdDisplayScript.java
private void createModifiedVdwFile(File vdwInputFile, File vdwOutputFile, int fitRank) { List<String> lines; List<String> modLines = new LinkedList<String>(); try {/* w w w .j a v a 2 s. co m*/ lines = FileUtils.readLines(vdwInputFile); } catch (IOException e) { throw new RuntimeException("Could not read form vdw file.\n" + vdwInputFile.getAbsolutePath(), e); } for (String line : lines) { String modifiedLine = line.replaceAll("[0-2]$", String.valueOf(fitRank)); modLines.add(modifiedLine); } try { FileUtils.writeLines(vdwOutputFile, modLines); } catch (IOException e) { throw new RuntimeException("Could not write to modified vdw file.\n" + vdwOutputFile.getAbsolutePath(), e); } }
From source file:gov.va.chir.tagline.dao.FileDao.java
public static Collection<Document> loadScoringLines(final File file, boolean hasHeader) throws IOException { final Map<String, Map<Integer, Line>> docMap = new HashMap<String, Map<Integer, Line>>(); // Assumes tab-delimited columns. May not be sorted. // Column labels may be on first line // Col 0 = NoteID // Col 1 = LineID // Col 2 = Text final int POS_DOC_ID = 0; final int POS_LINE_ID = 1; final int POS_TEXT = 2; final List<String> contents = FileUtils.readLines(file); for (int i = (hasHeader ? 1 : 0); i < contents.size(); i++) { final String l = contents.get(i); final String[] array = l.split("\t"); if (!docMap.containsKey(array[POS_DOC_ID])) { docMap.put(array[POS_DOC_ID], new TreeMap<Integer, Line>()); }/* w w w . j ava 2s.c om*/ int lineId = NumberUtils.toInt(array[POS_LINE_ID]); final Line line = new Line(lineId, array[POS_TEXT]); docMap.get(array[POS_DOC_ID]).put(lineId, line); } final Collection<Document> docs = new ArrayList<Document>(); for (String docId : docMap.keySet()) { docs.add(new Document(docId, new ArrayList<Line>(docMap.get(docId).values()))); } return docs; }
From source file:edu.ku.brc.specify.tools.StrLocaleFile.java
/** * @param path/*from www . j ava 2s . com*/ */ @SuppressWarnings("unchecked") private void loadCheckFile() { try { chkHash.clear(); File file = new File(dstPath + ".orig"); if (file.exists()) { List<String> lines = (List<String>) FileUtils.readLines(file); for (String line : lines) { if (!line.trim().startsWith("#") && line.indexOf('=') > -1) { int inx = line.indexOf('='); String key = line.substring(0, inx); String value = line.substring(inx + 1, line.length()); chkHash.put(key, value); } } } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:com.gargoylesoftware.htmlunit.source.BrowserVersionFeaturesSource.java
/** * Reverses the specified {@link BrowserVersionFeatures} to the other browsers (by modifying only * the configuration files)./* ww w . j a va2 s .c o m*/ * For example, if it is currently defined in IE8 and FF3, the BrowserFeatures will be removed from those browsers * configurations and added to the others ones. * * This is useful if you have something like "!browserVersion.hasFeature()" and you need to reverse the condition. * * @param features the feature to reverse * @throws IOException if an error occurs */ public void reverse(final BrowserVersionFeatures features) throws IOException { final File propertiesFolder = new File(root_, "src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration"); for (final File f : propertiesFolder.listFiles(new FileFilter() { public boolean accept(final File pathname) { return pathname.getName().endsWith(".properties"); } })) { final List<String> list = FileUtils.readLines(f); final String name = features.name(); if (list.contains(name)) { list.remove(name); } else { list.add(name); } Collections.sort(list); FileUtils.writeLines(f, list); } }
From source file:de.baumann.hhsmoodle.activities.Activity_todo.java
private void readItems() { try {//from w ww .j av a 2 s .com //noinspection unchecked items = new ArrayList<>(FileUtils.readLines(newFile())); } catch (IOException e) { items = new ArrayList<>(); } }
From source file:es.uvigo.ei.sing.adops.datatypes.Project.java
private void createNamesFile() throws IOException { final List<String> originalLines = FileUtils.readLines(this.originalFastaFile); final List<String> fastaLines = new ArrayList<>(); final List<String> namesLines = new ArrayList<>(); int i = 1;//from ww w . ja va2 s . com for (String l : originalLines) { if (l.startsWith(">")) { fastaLines.add(">C" + i); namesLines.add(l.substring(1) + " - C" + i); ++i; } else { fastaLines.add(l); } } FileUtils.writeLines(this.namesFile, namesLines); FileUtils.writeLines(this.renamedFastaFile, fastaLines); }
From source file:mi.RankInfo.java
int loadRandomSamples() throws Exception { List<String> vecLines = FileUtils.readLines(new File(rvgen.randomSamplesFileName())); int i = 0;//ww w. j a v a 2 s.co m for (String vecLine : vecLines) { o[i++] = new FloatByteRcd(i, rvgen.strToVec(vecLine)); } return i; }