不會的,RandomAccessFile對于過大文件,不會一次性全部讀出,而是一次一小段。我這里讀取365M的大文件,內(nèi)存占用也只有51KB
//------------------------
import help.Functions;
import java.io.RandomAccessFile;
public class A {
public static void main(String[] args) {
try {
long start = Runtime.getRuntime().freeMemory();
RandomAccessFile rF = new RandomAccessFile( "D:/cxz/壓縮軟件/S60-SDK-200634-3.1-Cpp-f.1090b.zip ", "r ");
for (int i = 0; i < 100; i++) {
if ((i % 16) == 0)
System.out.print( "\r\n ");
System.out.print(Functions.getByteHexStr(rF.readByte()) + " ");
}
long end = Runtime.getRuntime().freeMemory();
System.out.println( "\n\nused menory: " + (start - end) / 1024 + "KB ");
rF.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點(diǎn)擊舉報(bào)。