Check out example codes for "java read file text". It will help you in understanding the concepts better.

Code Example 1

try(BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
    StringBuilder sb = new StringBuilder();
    String line = br.readLine();

    while (line != null) {
        sb.append(line);
        sb.append(System.lineSeparator());
        line = br.readLine();
    }
    String everything = sb.toString();
}

Learn ReactJs, React Native from akashmittal.com