Skip to main content

Help with print writer method please

3 replies [Last post]
Joined: 2008-01-05
Points: 0

I am in AP COmputer Science and I am working on program that randomly generates the alphabet and then encrypts a word based on this alphabet. I have to output information to text file, but when ever I do, It overwrites the previous data.
Here is the section of code relating to my issue

PrintWriter outFile=new PrintWriter(new File("abcFile.txt"));
int keyNum=0;
while (file.hasNextInt())

outFile.print((keyNum+1)+" ");
for(int x=0;x

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-02-02
Points: 0

For UI code you can try the Java tutorial.

Joined: 2008-01-05
Points: 0

+message+" ");

outFile.close ();

Thanks for any and all help.
Also my course does go into user interface a lot, does any one know a good website to study on how to program user interfaces.

Thanks again, Feldman

Is it just my computer or part of it cut off?
above is the rest

Joined: 2006-12-18
Points: 0

Consider using FileWriter instead. Its constructor has a parameter to have it append rather than overwrite:

[code]PrintWriter outFile = new PrintWriter(new FileWriter("abcFile.txt", true));[/code]