ソースコードを読めば、自分で質問に答えることができます。
問題のScannerコンストラクターの実装は次のことを示しているようです。
public Scanner(File source) throws FileNotFoundException {
this((ReadableByteChannel)(new FileInputStream(source).getChannel()));
}
後でこれはリーダーにラップされます:
private static Readable makeReadable(ReadableByteChannel source, CharsetDecoder dec) {
return Channels.newReader(source, dec, -1);
}
そして、それはバッファサイズを使用して読み取られます
private static final int BUFFER_SIZE = 1024; // change to 1024;
構築チェーンの最後のコンストラクターでわかるように、次のようになります。
private Scanner(Readable source, Pattern pattern) {
assert source != null : "source should not be null";
assert pattern != null : "pattern should not be null";
this.source = source;
delimPattern = pattern;
buf = CharBuffer.allocate(BUFFER_SIZE);
buf.limit(0);
matcher = delimPattern.matcher(buf);
matcher.useTransparentBounds(true);
matcher.useAnchoringBounds(false);
useLocale(Locale.getDefault(Locale.Category.FORMAT));
}
したがって、スキャナーはファイル全体を一度に読み取らないようです。