private void writeToFile(Path path,String content) throws IOException {
  try (final BufferedWriter writer=Files.newBufferedWriter(path,Charset.defaultCharset())){
    writer.write(content);
  }
 }

private void writeToFile ( Path path , String content ) throws IOException { try ( final BufferedWriter writer = Files . newBufferedWriter ( path , Charset . defaultCharset ( ) ) ) { writer . write ( content ) ; } }
write content to file with the default charset of this java virtual machine for encoding . overwrite content if the file already exists .
