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


Java FileIO.getReader方法代码示例

本文整理汇总了Java中happy.coding.io.FileIO.getReader方法的典型用法代码示例。如果您正苦于以下问题:Java FileIO.getReader方法的具体用法?Java FileIO.getReader怎么用?Java FileIO.getReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在happy.coding.io.FileIO的用法示例。


在下文中一共展示了FileIO.getReader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readVisual

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public void readVisual(String path) throws IOException {
	System.out.println("Loading visual from " + path);

	BufferedReader br = FileIO.getReader(path);
	String line = null;
	while ((line = br.readLine()) != null) {
		line = line.trim();
		if (!line.isEmpty()) {
			String[] items = line.trim().split(",");
			String id = items[0];
			Integer tid = itemIds.get(id);
			if (tid != null) {
				Tweet t = tweets[tid];
				t.setVisual(items[1].trim().split("\\s+"));
			}
		}
	}
	br.close();
}
 
开发者ID:kite1988,项目名称:famf,代码行数:20,代码来源:DataDAO.java

示例2: readText

import happy.coding.io.FileIO; //导入方法依赖的package包/类
public void readText(String path) throws IOException {
	tweets = new Tweet[numItems()];
	
	System.out.println("Loading text from " + path);
	BufferedReader br = FileIO.getReader(path);
	String line = null;
	while ((line = br.readLine()) != null) {
		line = line.trim();
		if (!line.isEmpty()) {
			String[] items = line.split(",");
			String id = items[0];
			Integer tid = itemIds.get(id);
			if (tid != null) {
				Tweet t = new Tweet(items[0], tid);
				tweets[tid] = t;

				if (items.length == 2) {
					t.setText(items[1].trim().split(" "));
				} else {
					if (replaceMissing) {
						t.setText(numTextWords - 1);
					} else {
						t.setText(new String[0]);
					}
				}
			}
		}
	}
	br.close();
}
 
开发者ID:kite1988,项目名称:famf,代码行数:31,代码来源:DataDAO.java

示例3: ratings

import happy.coding.io.FileIO; //导入方法依赖的package包/类
@Test
public void ratings() throws Exception {
	String dirPath = "D:\\Research\\Datasets\\Ciao\\";
	String dest = dirPath + "formatted\\" + "ratings.txt";

	FileIO.deleteFile(dest);

	BufferedReader br = FileIO.getReader(dirPath
			+ "rating_with_timestamp.txt");
	String line = null;
	List<String> lines = new ArrayList<>();
	while ((line = br.readLine()) != null) {
		String[] data = line.trim().split("  ");

		int user = (int) Double.parseDouble(data[0]);
		int item = (int) Double.parseDouble(data[1]);
		double rate = Double.parseDouble(data[3]);

		line = user + " " + item + " " + rate;
		lines.add(line);

		if (lines.size() >= 1000) {
			FileIO.writeList(dest, lines, true);
			lines.clear();
		}
	}

	if (lines.size() > 0)
		FileIO.writeList(dest, lines, true);

	br.close();
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:33,代码来源:CiaoTest.java

示例4: trust

import happy.coding.io.FileIO; //导入方法依赖的package包/类
@Test
public void trust() throws Exception {
	String dirPath = "D:\\Research\\Datasets\\Ciao\\";
	String dest = dirPath + "formatted\\" + "trust.txt";

	FileIO.deleteFile(dest);

	BufferedReader br = FileIO.getReader(dirPath + "trust.txt");
	String line = null;
	List<String> lines = new ArrayList<>();
	while ((line = br.readLine()) != null) {
		String[] data = line.trim().split("  ");

		int trustor = (int) Double.parseDouble(data[0]);
		int trustee = (int) Double.parseDouble(data[1]);

		line = trustor + " " + trustee + " " + 1.0;
		lines.add(line);

		if (lines.size() >= 1000) {
			FileIO.writeList(dest, lines, true);
			lines.clear();
		}
	}

	if (lines.size() > 0)
		FileIO.writeList(dest, lines, true);

	br.close();
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:31,代码来源:CiaoTest.java


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