Java??????????
???????????? ???????[ 2013/11/12 11:18:14 ] ????????
????3?????卸?????????
/**
* ???????位????????????????????械????????
*/
public static void readFileByLines(String fileName) {
File file = new File(fileName);
BufferedReader reader = null;
try {
System.out.println("???????位?????????????味?????校?");
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
// ??味?????校????????null????????
while ((tempString = reader.readLine()) != null) {
// ????泻?
System.out.println("line " + line + ": " + tempString);
line++;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
????4???????????????
/**
* ?????????????
*/
public static void readFileByRandomAccess(String fileName) {
RandomAccessFile randomFile = null;
try {
System.out.println("?????????????????");
// ???????????????????????????
randomFile = new RandomAccessFile(fileName?? "r");
// ?????????????
long fileLength = randomFile.length();
// ??????????位??
int beginIndex = (fileLength > 4) ? 4 : 0;
// ???????????位?????beginIndex位?谩?
randomFile.seek(beginIndex);
byte[] bytes = new byte[10];
int byteread = 0;
// ??味?10???????????????????10???????????渭?????
// ????味?????????????byteread
while ((byteread = randomFile.read(bytes)) != -1) {
System.out.write(bytes?? 0?? byteread);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (randomFile != null) {
try {
randomFile.close();
} catch (IOException e1) {
}
}
}
}
??????

???路???
??????????????????
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