Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/03/2009, 13:07
oscarmoal
 
Fecha de Ingreso: marzo-2008
Mensajes: 63
Antigüedad: 16 años, 2 meses
Puntos: 0
Pregunta Ayuda con una Exception!

Hola, no se por que razón me marca la siguiente exception

existe.java:14: unreported exception java.io.IOException; must be caught or declared to be thrown
busca();
^

ya intente varias cosas pero no he logrado que funcione, por favor ayuda.

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

class existe extends Thread
{
   private boolean running = true;
   
   public existe() {}
   
   public void run()
   {
      while (running)
      {
         busca();
     
         try
         {
            System.out.println("");
            System.out.println("Realizando busqueda de actualización...");
            Thread.sleep(10000);
         }
         catch (InterruptedException e)
         {
            running = false;
         }
       }
   }
   
   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();
      }
   }
}
Saludos.