当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.lineIterator方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FileSearchMatcher.java

示例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();
	}
}
 
开发者ID:rhawan,项目名称:microservices-tcc-alfa,代码行数:19,代码来源:CargaCliente.java

示例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();
	}
}
 
开发者ID:rhawan,项目名称:microservices-tcc-alfa,代码行数:18,代码来源:CargaProduto.java

示例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();
	}
}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:24,代码来源:MRCFeatures.java

示例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();
	}
}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:17,代码来源:ConcFeatures.java

示例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();
	}
}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:18,代码来源:RankingSVM.java

示例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();
		}
	}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:15,代码来源:Stopwords.java

示例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);
    }
}
 
开发者ID:CyberAgent,项目名称:embulk-input-parquet_hadoop,代码行数:10,代码来源:JSONLinesIterator.java


注:本文中的org.apache.commons.io.FileUtils.lineIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。