Check out example codes for "Write an application that reads the content of the current directory and prints it to the screen. java". It will help you in understanding the concepts better.

Code Example 1

package com.vogella.java.files;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) throws IOException {
    String input = FilesUtil.readTextFile("file.txt");
    System.out.println(input);
    FilesUtil.writeToTextFile("copy.txt", input);

    System.out.println(FilesUtil.readTextFile("copy.txt"));

    FilesUtil.readTextFileByLines("file.txt");
    Path path = Paths.get("file.txt");
  }
}

Code Example 2

package com.vogella.java.files;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.List;

public class FilesUtil {
    public static String readTextFile(String fileName) throws IOException {
        String content = new String(Files.readAllBytes(Paths.get(fileName)));
        return content;
    }

    public static List<String> readTextFileByLines(String fileName) throws IOException {
        List<String> lines = Files.readAllLines(Paths.get(fileName));
        return lines;
    }

    public static void writeToTextFile(String fileName, String content) throws IOException {
        Files.write(Paths.get(fileName), content.getBytes(), StandardOpenOption.CREATE);
    }

}

Code Example 3

package com.vogella.eclipse.ide.first;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.stream.Stream;

public class ReadMANIFESTFile {
    public static void main(String[] args) throws IOException {
        String versionString = readStreamOfLinesUsingFiles();
        System.out.println(versionString);
    }

    private static String readStreamOfLinesUsingFiles() throws IOException {
        Stream<String> lines = Files.lines(Paths.get("META-INF", "MANIFEST.MF"));
        Optional<String> versionString = lines.filter(s -> s.contains("Bundle-Version:")).map(e-> e.substring(15).trim()).findFirst();

        lines.close();
        if (versionString.isPresent())
        {
            return versionString.get();
        }
        return "";
    }
}

Learn ReactJs, React Native from akashmittal.com