Help with making the user input to store in file
i understand how to print into a file but don't understand how to allow the user to input text so that it stores in the text file.
* Demonstrates how to append text to a file using Java.
* (Just add a "true" boolean parameter when creating the FileWriter.)
* Created by Alvin Alexander, [url=http://devdaily.com]devdaily.com | tutorials for java, linux, mac os x, iphone, ipad, uml, quality, testing[/url].
public class reservation
public static void main(String args)
PrintWriter pw = null;
// created as a separate variable to emphasize that I'm appending to this file
boolean append = true;
pw = new PrintWriter(new FileWriter(new File("output.txt"), append));
// a print writer gives you many more methods to write with
catch (IOException e)
// deal with the exception
Re: Help with making the user input to store in file
Is this a duplicated thread? Your other thread - http://www.javaprogrammingforums.com...html#post30136
Please keep all the information in 1 thread rather than starting a new one. I have closed your other thread.
This is easy to do using the link I provided you - http://www.javaprogrammingforums.com...ner-class.html
Scanner sc = new Scanner(System.in);
System.out.println("Add something: ");
String newText = sc.nextLine();