896+ Capstone Project is Available: Whatsapp: +91-7011258995, Email: sharecodepoint@gmail.com

How to store a word in Java program?

How to store a word in Java program?

Java: There are 5 ways to Save/Write String Into a File:

  1. Files.writeString(): The writeString() method of File Class in Java is used to write contents to the particular file.
  2. Files.write()
  3. FileWriter.
  4. BufferedWriter: BufferedWriter class is used to provide buffering for Writer instances. It makes the performance easy.
  5. 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); 
} 

Sharecodepoint

Sharecodepoint is the junction where every essential thing is shared for college students in the well-defined packets of codes. We are focused on providing you the best material package like Question papers, MCQ'S, and one NIGHT STUDY MATERIAL. facebook twitter youtube instagram

Post a Comment

Previous Post Next Post

Contact Form