Hello,
I have developed an ping program in java. But when I run the application then there is a "fatal exception" error message and the stack is:
My goal is to ping from my PC to an IP address. So how to continue the code to do this? Here's the code:java.lang.ArrayIndexOutOfBoundsException: 0
Exception in thread "main"
Code:Public class simulate_ping { Public static void hand(String args[]) { try { Socket t = new Socket(args[0], 7); DataInputStream dtinp = new DataInputStream(t.getInputStream()); PrintStream prst = new PrintStream(t.getOutputStream()); prst.System.out.println("Hello"); String str = dtinp.readLine(); if (str.equals("Hello")) System.out.System.out.println("Alive!") ; else System.out.System.out.println("Dead or echo port not responding"); t.close(); } catch (IOException e) { e.printStackTrace(); } } }
Bookmarks