3

I am going through Java's NIO class from Java 8.

Path dataPath = FileSystems.getDefault().getPath("SomeFile");

Files.write(dataPath,"\n Hello".getBytes("UTF-8"), StandardOpenOption.APPEND);

and

Path dataPath = FileSystems.getDefault().getPath("SomeFile");
BufferedWriter locFile = Files.newBufferedWriter(dataPath);

locFile.write("\n Hello");

Is it just that we are writing in terms of Bytes with Files.write() and Using a BufferedWriter for directly writing the text ?

shmosel
  • 49,289
  • 6
  • 73
  • 138
D3VLPR
  • 751
  • 3
  • 8
  • 13
  • For one thing, you're using different options. For another you're using a `BufferedWriter`. I don't really understand the question. – shmosel Jun 21 '17 at 01:50
  • I'm just trying to find the difference between two implementations. Both of them are used to write into a File. So which is more preferred in different situations ? – D3VLPR Jun 21 '17 at 01:58
  • 1
    https://stackoverflow.com/a/12350364/1553851 – shmosel Jun 21 '17 at 02:01
  • 1
    just these two? there are more :-) you can start here: http://www.baeldung.com/java-write-to-file – Serge Jun 21 '17 at 02:22

0 Answers0