Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/12/2011, 13:44
Pacheco_1990_2
 
Fecha de Ingreso: diciembre-2011
Mensajes: 30
Antigüedad: 12 años, 4 meses
Puntos: 0
Problema con creacion de objetos

Bueno llevo horas por no decir dias con este problema os cuento estoy haciendo una clase para crear objetos y poder trabajar mejor con los file .txt.

Aquí están los atributos de clase y lo constructores.

Código Javascript:
Ver original
  1. public class FicheroPalabra {
  2.  
  3.  
  4.     private static int x;
  5.     private static FileReader fin = null;
  6.     private static FileWriter fin1=null;
  7.     private static int x1;
  8.     char c;
  9.  
  10.     public FicheroPalabra(String nom) throws Exception {
  11.         fin = new FileReader(nom);
  12.         x=fin.read();
  13.        
  14.     }
  15.  
  16.     public FicheroPalabra (String nom, int numero)throws Exception{
  17.         fin1=new FileWriter(nom);
  18.  
  19.     }

El programa principal es este:

Código Javascript:
Ver original
  1. FicheroPalabra SALIDA=new FicheroPalabra("C:/Pruevas/SORTIDA.TXT",1);              
  2.         FicheroPalabra TEXTO=new FicheroPalabra("C:/Pruevas/TEXT.txt");  //Primero fichero
  3.         FicheroPalabra DICCIONARIO=new FicheroPalabra("C:/Pruevas/DICCIONARI.TXT");  //Segunfo fichero
  4.  
  5.  
  6.         Palabra f=new Palabra();
  7.         Palabra d=new Palabra();
  8.  
  9.  
  10.             TEXTO.LeerYGuardar(f);
  11.             System.out.print(f.toString());
  12.             SALIDA.Escritura(f);
  13.             System.out.print (" ");
  14.  
  15.         DICCIONARIO.LeerYGuardar(d);
  16.        System.out.print(d.toString());
  17.        SALIDA.Escritura(d);
  18.        System.out.print ("bos");
  19.        
  20.         SALIDA.CerrarFichero1();
  21.         DICCIONARIO.CerrarFichero();
  22.         TEXTO.CerrarFichero();
  23.  
  24.     }

Mi problema es simple si pongo el objeto TEXTO primero y despues el DICCIONARIO solo puedo usar el DICCIONARIO es como si ese objeto machacará al otro. ¿Un objeto no es independiente de otro?

Por ejmplo si hago TEXTO.LeerYGuaradar(f); Me guarda la palabra que hay en DICCIONARIO y no en TEXTO.

No se si me explico muy bien no quiero colgar todo la clase ni todo el programa porque sería demasiado largo. He intentado explicarme lo mejor posible.

Ojala podáis ayudarme :D.