porblemas con las excepciones
Publicado por Sergio (2 intervenciones) el 18/10/2008 18:29:44
Hola a todos:
Estoy haciendo una intefaz grafica en java pero al momento de anexar el evento a un boton me marca el siguiente error
unreported exception java.io.IOException; must be caught or declared to be thrown
realizaAnalisisLexico();
La parte de codigo en la que me marca el error es la siguiente
lex.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent evento)
{
realizaAnalisisLexico();
}
});
Y el metodo que esta llamando es el siguiente
public void realizaAnalisisLexico()throws IOException
{
try
{
LeeArchivo leearchivo;
if (name.isFile())
{
leearchivo=new LeeArchivo(name);
try
{
BufferedReader err1=new BufferedReader(new FileReader("Errores.txt"));
BufferedReader rep1=new BufferedReader(new FileReader("Reporte.txt"));
String lineas1=" ", lineas2;
String ln1=" ", ln2=" ";
while((lineas1=err1.readLine())!=null)
{
ln1=ln1+lineas1+" ";
}
while((lineas2=rep1.readLine())!=null)
{
ln2=ln2+lineas2+" ";
}
a2.setText(ln2);
a3.setText(ln1);
}
catch(IOException e)
{
}
}
else
{
JOptionPane.showMessageDialog(this,"Primero abre un Archivo");
}
}
catch(IOException e)
{
}
}
Espero que alguien me pueda ayudar y gracias
Estoy haciendo una intefaz grafica en java pero al momento de anexar el evento a un boton me marca el siguiente error
unreported exception java.io.IOException; must be caught or declared to be thrown
realizaAnalisisLexico();
La parte de codigo en la que me marca el error es la siguiente
lex.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent evento)
{
realizaAnalisisLexico();
}
});
Y el metodo que esta llamando es el siguiente
public void realizaAnalisisLexico()throws IOException
{
try
{
LeeArchivo leearchivo;
if (name.isFile())
{
leearchivo=new LeeArchivo(name);
try
{
BufferedReader err1=new BufferedReader(new FileReader("Errores.txt"));
BufferedReader rep1=new BufferedReader(new FileReader("Reporte.txt"));
String lineas1=" ", lineas2;
String ln1=" ", ln2=" ";
while((lineas1=err1.readLine())!=null)
{
ln1=ln1+lineas1+" ";
}
while((lineas2=rep1.readLine())!=null)
{
ln2=ln2+lineas2+" ";
}
a2.setText(ln2);
a3.setText(ln1);
}
catch(IOException e)
{
}
}
else
{
JOptionPane.showMessageDialog(this,"Primero abre un Archivo");
}
}
catch(IOException e)
{
}
}
Espero que alguien me pueda ayudar y gracias
Valora esta pregunta


0