當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。