I have to read a text file in Java, for that I am using below code:
Scanner scanner = new Scanner(new InputStreamReader(
ClassLoader.getSystemResourceAsStream("mock_test_data/MyFile.txt")));
scanner.useDelimiter("\\Z");
String content = scanner.next();
scanner.close();
As far as I know String
has MAX_LENGTH 2^31-1
But this code is reading only first 1024 characters from input file(MyFile.txt).
I am not able to find the reason.