Java: There are 5 ways to Save/Write String Into a File:
- Files.writeString(): The writeString() method of File Class in Java is used to write contents to the particular file.
- Files.write()
- FileWriter.
- BufferedWriter: BufferedWriter class is used to provide buffering for Writer instances. It makes the performance easy.
- PrintWriter: Prints formatted representations of objects to a text-output stream.
Example:
String s="abcd"; char[] a=s.toCharArray(); for(char c:a){ System.out.println(c); }