How to write content from a String into File in Java?

Views: 1 Ask New Question


I have a string that to be written into a File, How can i do that in Java?

On By

1 Answer


String contentTobeWritten = "This is the new content you will see in file";
Files.write(Paths.get("/path/to/file"), contentTobeWritten.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
On By


Answer This Question