-
Problem in File Creation
I am a java beginner... I am doing a small standalone application.. In which i am using files..
In my code i want to get customer details and to store it in a file..i am using following code for doing that...
Code:
File customer = new File("customer details.txt");
FileOutputStream fop1 = new FileOutputStream(customer);
fop1.write(customerName.getBytes());
fop1.write(customerCompany.getBytes());
fop1.write(customerAddress.getBytes());
fop1.flush();
fop1.close();
But while using this code..for each execution one file is created and details getting added and in next execution the old file is deleted along with the details....but i need one file is to be created and only details to be added in each execution...help me pls.... :confused:
-
See the API docs for FileOutputStream, namely its varying constructors. There is a way to "open" the file in append mode.