Hello
I'm having some trouble writing to text and object files in java. Basically i need to delete the contents of the file before i write the new information on it...which i'm not being able to do.
well this is what i have in terms of code for the text file:
try
{
fW = new BufferedWriter(new FileWriter("Pedidos_Formacao.txt"));
fW.write("Pedido");
fW.newLine();
fW.close;
}
and this is for the object file:
try
{
os = new ObjectOutputStream(new FileOutputStream("Utilizadores.bin"));
User x = new User("João",1);
os.writeObject(x);
}
I have no problem writing but i need to delete the contents of the file before doing so or else this code will simply add the new information to the one that was already in the file.
Can anyone help me?
Thanks in advance
João