Home » Java » What is the equivalent method in Java to the method file.read(5) in Python

What is the equivalent method in Java to the method file.read(5) in Python

Posted by: admin October 26, 2017 Leave a comment

Questions:

I am trying to open a file and read 5 bytes each time.

In Python, we can use

fp = open('test.txt', 'r');
fp.read(5);

I have looked up many methods in Java. most of them can read line by line. Like

BufferedReader br = new BufferedReader(new FileReader("test.txt"));
string s = br.readline();

So, is there any equivalent method in Java can read a file 5 bytes each time? Thanks!

Answers: