This site requires JavaScript, please enable it in your browser!
Greenfoot back
RevoltecX7
RevoltecX7 wrote ...

2018/4/7

IOException/try

RevoltecX7 RevoltecX7

2018/4/7

#
Hello, can someone help me convert
byte[] msg = new String("b").getBytes(); 
 
        DatagramSocket client = new DatagramSocket(); 
 
        InetAddress inetAddr = InetAddress.getLocalHost(); 
        SocketAddress socketAddr = new InetSocketAddress(inetAddr, 8888); 
 
        DatagramPacket sendPacket = new DatagramPacket(msg, msg.length, socketAddr); 
 
        client.send(sendPacket); 
 
        client.close();
to that IOException -> try/catch (etc.)??? idk what excatly it must containt. But I want it for my multiplayer game. :)
//to something like this I think: 
try {

}catch (IOException e) {
    
}
This is original
Vercility Vercility

2018/4/7

#
Ehh, everything u wanna do goes into try, then whatever should happen when it fails goes into catch e.g
System.out.println("something went wrong.") ;
You need to login to post a reply.