Skip to content

Instantly share code, notes, and snippets.

@marawannwh
Created December 15, 2012 15:12
Show Gist options
  • Save marawannwh/4296198 to your computer and use it in GitHub Desktop.
Save marawannwh/4296198 to your computer and use it in GitHub Desktop.
import java.util.StringTokenizer;
import java.util.NoSuchElementException;
public class IpCutter3 {
public static void main (String[]args) {
StringTokenizer Q = new StringTokenizer(args[0]);
String[]k=new String[4];
try {
for (int i=0;i<4;i++)
k[i]=Q.nextToken(".");
}
catch (NoSuchElementException ex ) {
System.out.println("Error : You have entered an invalid IP address");
System.exit(0); }
for (int i=0;i<4;i++)
System.out.println(k[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment