Como agrego una cadena al final de un archivo(este tiene texto)
Bueno, lo q pasa es q quiero agregar una cadena al final de un archivo, he buscado en la ayuda y encontre q con un FileWriter se puede hacer esto pero segun yo lo hago tal y como dice pero no me agrega el texto, si no q elimina el q tiene el archivo. y yo solo quiero q lo agregue aunq el archivo tenga texto, q no lo borre.
Bueno aqui dejo mi funcion para q la chequen y me digan e n q estoy mal... Gracias
public void Anidar(String ruta)
{
try{
BufferedReader entrada=new BufferedReader(new InputStreamReader(System.in));
//File f=new File(ruta);
FileWriter fw=new FileWriter(ruta,true);
PrintWriter pw=new PrintWriter(fw);
String Text=entrada.readLine();
//fw.write(Text);
pw.println(Text);
fw.close();
}
catch(IOException e){
System.out.println("Error "+e);
}
}
Bueno aqui dejo mi funcion para q la chequen y me digan e n q estoy mal... Gracias
public void Anidar(String ruta)
{
try{
BufferedReader entrada=new BufferedReader(new InputStreamReader(System.in));
//File f=new File(ruta);
FileWriter fw=new FileWriter(ruta,true);
PrintWriter pw=new PrintWriter(fw);
String Text=entrada.readLine();
//fw.write(Text);
pw.println(Text);
fw.close();
}
catch(IOException e){
System.out.println("Error "+e);
}
}