Java - Read a big file (few GB) without exception
问题 This question is very short. I have a File Datei.trec-3,99 GB and i read it with this code: 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) { e.printStackTrace(); } System.out.println(content); } } and this is the output: Exception in thread "main" java.lang.OutOfMemoryError: Required array size too large at java.nio.file.Files.readAllBytes(Unknown