本文整理汇总了Java中org.apache.commons.io.FileUtils.lineIterator方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.lineIterator方法的具体用法?Java FileUtils.lineIterator怎么用?Java FileUtils.lineIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.lineIterator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSearchTextPresentInLinesOfFile
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private boolean isSearchTextPresentInLinesOfFile(File f) {
LineIterator it = null;
try {
it = FileUtils.lineIterator(f, "UTF-8");
while (it.hasNext()) {
String line = it.nextLine();
if (line.contains(searchText)) {
return true;
}
}
return false;
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
LineIterator.closeQuietly(it);
}
}
示例2: realizarCargaArquivo
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void realizarCargaArquivo() {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource(NOME_ARQUIVO).getFile());
LineIterator it = null;
try {
it = FileUtils.lineIterator(file, "UTF-8");
while(it.hasNext()) {
String linha = it.nextLine();
String[] dados = linha.split("\\|");
inserirCliente(dados[0], dados[1], dados[2], dados[3], dados[4],
dados[5], dados[6], dados[7], dados[8], dados[9]);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
it.close();
}
}
示例3: realizarCargaArquivo
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void realizarCargaArquivo() {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource(NOME_ARQUIVO).getFile());
LineIterator it = null;
try {
it = FileUtils.lineIterator(file, "UTF-8");
while(it.hasNext()) {
String linha = it.nextLine();
String[] dados = linha.split("\\|");
inserirItemAvaliado(dados[0], dados[1], dados[2], dados[3], dados[4]);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
it.close();
}
}
示例4: loadData
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void loadData() {
File f = new File(getClass().getClassLoader().getResource(FILE).getFile());
try {
LineIterator i = FileUtils.lineIterator(f);
String[] header = null;
while (i.hasNext()) {
String[] cols = i.next().split("\t");
if (cols[0].equals("word")) {
for (int c = 1; c < cols.length; c++)
this.data.put(cols[c], new HashMap<String, Integer>());
header = cols;
} else {
String w = cols[0].toLowerCase();
for (int c = 1; c < cols.length; c++) {
if (cols[c].length() > 0)
this.data.get(header[c]).put(w, Integer.parseInt(cols[c]));
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: loadData
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void loadData() {
File f = new File(getClass().getClassLoader().getResource(FILE).getFile());
try {
LineIterator i = FileUtils.lineIterator(f);
while (i.hasNext()) {
String[] cols = i.next().split("\t");
if (!cols[0].equals("Word")) {
String w = cols[0].toLowerCase();
Double s = Double.parseDouble(cols[2]);
this.data.put(w, s);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: setWeights
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void setWeights(String fileName) {
File f = new File(fileName);
try {
LineIterator i = FileUtils.lineIterator(f);
List<Double> weights = new ArrayList<Double>();
while (i.hasNext()) {
String line = i.next().trim();
if (line.length() > 0)
weights.add(Double.parseDouble(line));
}
this.weights = new double[weights.size()];
for (int j = 0; j < weights.size(); j++)
this.weights[j] = weights.get(j);
} catch (IOException e) {
e.printStackTrace();
}
}
示例7: Stopwords
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public Stopwords(String fileName) {
this.stopwords = new HashSet<String>();
File f = new File(getClass().getClassLoader().getResource(fileName).getFile());
try {
LineIterator i = FileUtils.lineIterator(f);
while (i.hasNext()) {
this.stopwords.add(i.next());
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例8: JSONLinesIterator
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public JSONLinesIterator(File file)
{
try {
inner = FileUtils.lineIterator(file);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}