ReadFileTest read = new ReadFileTest();
read.setPath("aaaa.txt");
while (read.nextRecord() != -1) {
System.out.println(read.returnRecord());
}
public ReadFileTest() {
file = new BufferedReader(new InputStreamReader(System.in), 1);
}
path = filePath;
try {
file = new BufferedReader(new FileReader(path));
} catch (FileNotFoundException e) {
System.out.println("file not found");
}
public void setPath(String filePath) throws FileNotFoundException {
path = filePath;
file = new BufferedReader(new FileReader(path));
}
ReadFileTest read = new ReadFileTest();
try {
read.setPath("aaaa.txt");
while (read.nextRecord() != -1) {
System.out.println(read.returnRecord());
}
} catch (FileNotFoundException e) {
System.out.println("文件不存在");
}
// while ((record = file.readLine()) != null)//只读入一行进缓冲区
// {
record = file.readLine();
if (record.regionMatches(0, "Users of", 0, 8) == true) {
record = file.readLine();
if (record == null)
returnInt = -1;
else {
token = new StringTokenizer(record);
returnInt = token.countTokens();
if (record.regionMatches(0, "Users of", 0, 8) == true) {
int i = record.indexOf(":");
int j = record.lastIndexOf("of");
int k = record.indexOf("license");
int l = record.lastIndexOf("license");
lineRecord[0] = record.substring(9, i);
lineRecord[1] = record.substring(i + 12, k);
lineRecord[2] = record.substring(j + 2, l);
}
}