-1

Code file here:

http://pastebin.com/X3HW8gPy

Code error here:

http://imageshack.us/f/152/erroriojava.png/

I don't know why happens that.

4

2 に答える 2

1

Java has 2 types of exceptions: checked and unchecked. Checked exceptions require the programmer to handle them explicitly when a method may throw them. In your case, IOException is a checked exception, because it doesn't extend RuntimeException, and the accept method may throw it.

There are 2 ways to handle checked exceptions, just like the error message says: they can be caught (using a try..catch block) or declared to be thrown (using the throws keyword for your method). If you choose the 2nd option, then the caller of your method becomes responsible for handling the exception.

You can find a lot more details and examples if you search for java checked exceptions. Good luck!

于 2013-03-11T23:46:35.847 に答える
-1

At least, all errors included on your image are related to unreported exception

java.io.IOException

So, you should include try catch blocks for following lines or

throws IOException 

from your methods

flujosES() 

and

waitConexion()

Line 57 : printMensaje( "Conexión recibida de: " + conexion.getInetAddress().getHostName() );

Line 120: salida.flush();

line 121: entrada = new ObjectInputStream( conexion.getInputStream() );

Line 122: printMensaje( "\nSe recibieron los flujos de E/S\n" );

于 2013-03-12T00:15:37.653 に答える