Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/06/2012, 10:44
baterista41
 
Fecha de Ingreso: junio-2012
Mensajes: 32
Antigüedad: 11 años, 11 meses
Puntos: 1
Duda con archivos

amigos tengo un proyecto de leer un archivo de texto y cambiar palabras que esten dentro de ella lo ise con el StringTokenizer y hasta hai todo bien pero al momento de escribirlo en un txt nada mas me guarda la primera linea si solo hago un simple System.out.println(conversion2); dentro del while si me imprime todo.pero cuando lo escribo no igual y si me pudieran dejar como lo meto a un arreglo para despues escribirlo seria de gran ayuda porfavor

EL DOCUMENTO DE TEXTO QUE ESTA EN EL ESCRITORIO CONTIENE ESTO

LA SIb DO# LA

----------------------------------------------------------------------------------------------------
package leerdirectorio;


import java.io.*;

public class Archivo {

public String leerGrafico()
{
File f;
javax.swing.JFileChooser j= new javax.swing.JFileChooser();
j.showOpenDialog(j);
String path= j.getSelectedFile().getAbsolutePath();
String lectura="";
f = new File(path);
try{
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String aux;
while((aux = br.readLine())!=null)
lectura = lectura+aux+"\n";
}catch(IOException e){}
return lectura;
}



}

!!!AKI EL PROBLEMA!!!!!!!!!

package leerdirectorio;
import java.util.*;
import java.io.*;
public class Leer {

public static void main(String args[]){
String TokenActual;
String conversion1=null;
String conversion2=null;
Archivo a=new Archivo();
String l=a.leerGrafico();
StringTokenizer tokens=new StringTokenizer(l);

while(tokens.hasMoreTokens()){
TokenActual=tokens.nextToken();
conversion1=TokenActual.replaceAll("LA", "MIB");
conversion2=conversion1.replaceAll("SIb","RE");


}
try
{
PrintWriter stdOut = new PrintWriter(new FileWriter("Transportadas.txt"));
stdOut.println(conversion2);
stdOut.close();
}
catch (IOException e)
{
}
}
}