????????????????????????????
?????????????commons-io??FileUtils??????ж??
?????????????Scanner???ж??
??????????????cache???ж??
????????????С??102M
???????commons-io??FileUtils????ж??
????public static void testReadFile() {
????try {
????LineIterator lineIterator = FileUtils.lineIterator(new File("D:/test.log")?? "UTF-8");
????while (lineIterator.hasNext()) {
????String line = lineIterator.nextLine();
????System.out.println(line);
????}
????} catch (IOException e) {
????e.printStackTrace();
????}
????}
????????????8??????
???????Scanner???ж????
public static void testScannerReadFile() {
FileInputStream fileInputStream = null;
Scanner scanner = null;
try {
fileInputStream = new FileInputStream("D:/test.log");
scanner = new Scanner(fileInputStream?? "UTF-8");
while (scanner.hasNext()) {
String line = scanner.nextLine();
System.out.println(line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (scanner != null) {
scanner.close();
}
}
}
????????????10??????
???????cache???
public static void readCache() {
String filename = "D:/test.log";
File file = new File(filename);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file)?? 10 * 1024 * 1024);   //??????? ???????
String tempString = null;
while ((tempString = reader.readLine()) != null) {
System.out.println(tempString);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
????????????8?????????commons-io??FileUtils???????£???????????и??????????б????????и???????????????в??????