I wonder why java.nio is based in static methods, I mean in java.io you create a file and then use his methods, is something like:
File file = new File("myFile");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String readLine = bufferedReader.readLine();
Where each object has its own methods.
java.nio works in a different way, you use static methods and it forces you to always pass the file to work as a parameter.
Path file = Paths.get("myFile");
BufferedReader bufferedReader = Files.newBufferedReader(file);
String readLine = bufferedReader.readLine();
Path source = Paths.get("source");
Path target = Paths.get("target");
Files.copy(source, target);
There is less code to write since nio provides useful methods (like newBufferedReader) directly in the class. but it could have been done in instance methods as well so you wouldn't have to pass a path as parameter.
Why this change of paradigm? Whata are the hidden advantages?