Home » Java » Read large gigabytes file in Java

Read large gigabytes file in Java

Read large file in gigabytes using Java, requires simple techniques. We can not read all files and store in memory it consumes much more resources. Alternatively, we can read line by line and process it (displaying for example). In this talk, I’ll show a simple Java program that could do that task. Here is the code :

Save the file as BacaFileInputStream.java and compile it. To execute that file, and display 10 lines, use command line like :

java BacaFileInputStream 10

Happy coding !


Leave a comment

Your email address will not be published. Required fields are marked *