Here there is a snippet taken from here:
import static java.nio.file.StandardOpenOption.*;
Path logfile = ...;
// Convert the string to a
// byte array.
String s = ...;
byte data[] = s.getBytes();
try (OutputStream out = new BufferedOutputStream(
logfile.newOutputStream(CREATE, APPEND))) {
...
out.write(data, 0, data.length);
} catch (IOException x) {
System.err.println(x);
}
However I cannot compile the logfile (which is a Path object) with newOutputStream method... only with Files.newOutputStream(path,StandardOpenOption..);