Hi,

I have write a method to save amounts, the method has 1 argument which is where the amounts returned by a toString should be saved as text.
I have no idea what to do and my searching on google or text books has been not helpful :(

public void saveAmounts(String output)
{
   //No idea
}

Please help

Whow, your question is either very vague/messed-up or I'm going mad..

Let me just make sure what you mean here, you want this method, to Create a file with the name of the String that has been passed as the arguments for the method?
OR
Do you want to just write the String to a file?

Sorry just want to write the string to the file it has already been created

Oh okay perfect,

BufferedWriter out;
String yourString = output;
out = new BufferedWriter(new FileWriter("yourFileName.txt",true));
out.write(yourString);
out.newLine();
out.close();

You might have to tweak some of this code, but otherwise put this in your method body and I'm sure you'd be able to make this work..

Not to carp or anything, but searching on "java write to file" produced 4 million results in bing and 44 million in google. The first page results on both included the information that would have led you to this answer or one very like it.

This question has already been answered. Start a new discussion instead.