???????????????
???????????? ???????[ 2015/9/28 15:40:40 ] ??????????????? ???????
????????????????????????????
?????????????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???????£???????????и??????????б????????и???????????????в??????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11