File Writer Write text in .txt file.
import java.util.Scanner;
import java.io.FileWriter;
import java.io.File;
class filewrite1
{
public static void main(String args[])throws Exception
{
Scanner scan = new Scanner(System.in);
FileWriter obj = new FileWriter(new File("jyoti.txt"));
System.out.println("enter the text-:>");
String str = "";
while(!((str=scan.next()).equals("~")))
{
obj.write(str+" ");
}
System.out.println("saved");
obj.close();
}
}