Exception in thread "main" java.lang.ArrayIndexOutOfBoundsExceptio
Hi peeps
I am having trouble with my codes.
My codes are as follows
import java.net.*;
import java.util.*;
class EchoClient {
public static void main( String args[] ) throws Exception {
DatagramSocket socket = new DatagramSocket();
socket.setSoTimeout( 5000 );
byte[] buffer = args[1].getBytes();
DatagramPacket packet = new DatagramPacket(buffer,buffer.length,InetAddress.ge tByName(args[0]),7);
socket.send( packet );
Date timeSent = new Date();
socket.receive( packet );
Date timeReceived = new Date();
System.out.println( ""+(timeReceived.getTime()-timeSent.getTime())+" ms "+new String(packet.getData(),0,packet.getLength()) );
}
}
and the error is
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at EchoClient.main(EchoClient.java:9)
Anyone can assist?