Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/03/2009, 13:53
hoolligan666
 
Fecha de Ingreso: octubre-2005
Ubicación: Córdoba, Veracruz
Mensajes: 42
Antigüedad: 18 años, 6 meses
Puntos: 0
Respuesta: Ayuda con una Exception!

Lo que sucede es que, estás diciendo que tu método busca() lanza la excepción IOException, así que deberías cacharla en algún lugar.
Modifiqué un poco el código que pegaste, a ver si así te funciona bien (las líneas que agregué/modifiqué tienen comentario a la derecha):

Código:
import java.io.*;
import java.util.*;

class existe extends Thread
{
   private boolean running = true;
   
   public existe() {}
   
   public void run()
   {
      while (running)
      {
         try{                                    
          busca();                      //mueves el busca() dentro del try
          System.out.println("");
          System.out.println("Realizando busqueda de actualización...");
          Thread.sleep(10000);
         }
         catch (InterruptedException e)
         {
            running = false;
         }
         catch (IOException e){           //aquí estás cachando la excepción de busca()
                                          //aquí deberías hacer algo con esa excepción (¿mostrar un mensaje, quizá?
         }
       }
   }
   
   public static void main(String[] args) throws IOException
   {
      new existe().start(); 
   }
   
   public static void busca() throws IOException
   {
      try
      {
         String sFichero = "Eambascu.tst";
         File fichero = new File(sFichero);
          
         String cad1 = "flag.txt";
         FileInputStream tream = new FileInputStream(cad1);
         BufferedReader in = new BufferedReader(new InputStreamReader(tream));
         String line = in.readLine();
         String line2 = "0";
         
         if (fichero.exists())
         {
            System.out.println("El archivo " + sFichero + " existe");
            
            if (line.equals(line2))
            {   
               String cad = "flag.txt";
               File TextFile = new File(cad);
               FileWriter TextOut;
               try
               {
                  TextOut = new FileWriter(TextFile);
                  TextOut.write("1");
                  System.out.println("Se esta transmitiendo el archivo...");
                  TextOut.close();
               }
               catch(IOException e)
               {
                  e.printStackTrace();
               }
                   
               System.out.println("Trabajando con la bandera");
               
               String cad2 = "flag.txt";
               File TextFile1 = new File(cad2);
               FileWriter TextOut1;
               try
               {
                  TextOut1 = new FileWriter(TextFile1);
                  TextOut1.write("0");
                  System.out.println("Y se puede usar");
                  TextOut1.close();
               }
               catch(IOException e)
               {
                  e.printStackTrace();
               }
            } 
            else
            {
               System.out.println("El archivo esta siendo usado");
            }   
         }  
         else
         {
            System.out.println("El archivo no se encuentra");
         }
         limpiar(50-2);
      }
      catch (IOException e) 
      {
         throw new IOException(e.getMessage());
      }
   }
      
   public static void limpiar(int lineas)
   {
      for (int i=0; i < lineas; i++)
      {
         System.out.println();
      }
   }
}
Si sigue sin funcionar escribe de nuevo, a ver si puedo ayudarte.
¡Saludos!