Having a bit of trouble writing to a File. If I populate the .txt File and use a FileReader with a BufferedReader like this:
[code]BufferedReader in = new BufferedReader(new FileReader("password.txt"));
String input = in.readLine();[/code]
I can read the contents of the File. But when it comes to writing to the .txt File using a PrintWriter and a FileWriter like this:
[code]PrintWriter out = new PrintWriter(new FileWriter("password"));
The .txt File just becomes empty, even if the File doesn't exist or is empty to begin with, all I get is an empty File. I'm a bit confused, and was wondering if anyone could shine some light on the matter, and tell me how to go about writing to a .txt File successfully. I've even tried a RandomAccessFile to write to a file, without any luck. So any help on writing to a File using a PrintWriter and a FileWriter would be appreciated.
Thanks in advance,
0 · ·