本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}