Results 1 to 2 of 2
  1. #1
    ethann_91 is offline Member
    Join Date
    Jan 2010
    Rep Power

    Default Error on reading text from a file.

    I am new to java and right now stuck in a simple issue i believe,
    i am trying to make a applt. that lets the user save information on to a file and
    then read the information saved. My problem is that if the user saved information on to the file and then reads the information once everything goes perfectly and the information is displayed exactly as he saved it, but if the user runes the WHILE statement again and reads the same exact information again i get a error.

    Here is the code:

    1. Saving Text on to file:
    Java Code:
    if (respuestaPrimera.equalsIgnoreCase("E")) {
              String respuesta = "s";    
              while (respuesta.equalsIgnoreCase("s") ) {
    			 String cantidadExtraccion1;
    			 String razon;
    			 String fecha;
    			 System.out.print("Cantidad de Extraccion o Gasto?: ");
    			 cantidadExtraccion1 =;
    			 Double extraccionDouble = Double.valueOf(cantidadExtraccion1).doubleValue();
    			 System.out.print("Razon de Extraccion: ");
    			 razon =;
    			 System.out.print("Fecha de Extraccion: ");
    			 fecha =;
    			 saldo.deduce(util.leersActual(), extraccionDouble);
    			 System.out.print("Quisiera Realizar Otra Extraccion (S - N): ");
    			 respuesta =;
    2.Reading Text From File:
    Java Code:
    if (respuestaPrimera.equalsIgnoreCase("x")) {
            	  for (int i = 0; i < cuentaExtracciones; i++ ){
            		  String razon1;
            		  String fecha1;
            		  String cantidad1;
            		  try {
            		  fecha1 = flujoObjetoEntradaF.readObject().toString();
            		  razon1 = flujoObjetoEntradaR.readObject().toString();
            		  cantidad1 = flujoObjetoEntradaC.readObject().toString();
            		  System.out.print(" Fecha: " + fecha1);
            		  System.out.print(" Cantidad: " + cantidad1);
            		  System.out.print(" Razon: " + razon1);
            		  catch (ClassNotFoundException e) {
    The Error:
    Exception in thread "main" Not a valide controler.
    at Method)
    at$BlockDataInputStream.pee k(
    at$BlockDataInputStream.pee kByte(
    at com.eitan.dispaly.Display.main(

    Any ideas how can i read the file more then once without getting this error?

    PD: I do .close() bought the read and write object after every run thorough them.
    And obviously this error only appears if i am trying to read the file again.
    Last edited by ethann_91; 01-19-2010 at 03:18 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    So how many times and in how many fora are you going to place this same darn question? Please do not cross-post without notifying others that you are doing so as it will only bring you flames. For details on why, please look here: BeForthrightWhenCrossPostingToOtherSites

Similar Threads

  1. Reading Integers from a text file
    By tress in forum New To Java
    Replies: 6
    Last Post: 02-26-2011, 05:45 PM
  2. Reading a text file
    By diegosened in forum New To Java
    Replies: 4
    Last Post: 01-15-2010, 11:32 PM
  3. Reading Text File with Certain Conditions
    By balaji csc in forum New To Java
    Replies: 1
    Last Post: 11-10-2009, 11:38 AM
  4. Reading two text file and sum them up
    By matt_well in forum New To Java
    Replies: 36
    Last Post: 07-22-2008, 02:55 AM
  5. Reading text file
    By Lennon-Guru in forum New To Java
    Replies: 1
    Last Post: 12-15-2007, 11:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts