2017-05-04 5 views
-6

この質問は非常に短いです。 私はGBファイル例外なく3GBファイルを読む

Datei.trec-3,99を持っていると私は、このコードでそれを読む:

public class Main { public static void main(String[] args) { byte[] content = null; try { content = Files.readAllBytes(Paths.get("D:", "Videos","Captures","Datei.trec")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(content); } } 

と、これが出力されます:

Exception in thread "main" java.lang.OutOfMemoryError: Required array size too large 
    at java.nio.file.Files.readAllBytes(Unknown Source) 
    at Main.main(Main.java:13) 

そうあり例外なしで配列を書き込むためのオプション(FileInputStreamなど)?

+0

コンテンツはサイズが制限されているため、オーバーフローしています.... –

+0

私は知っていますが、代わりにコンテンツを読むべきですか? – Niton

+3

あなたはそれをストリーミングします。 – pandaadb

答えて

関連する問題