Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. public static IPAddress fromString(String string) throws IPFormatException{
  2. String[] splittedString = string.split("\\.");
  3. int[] tempArray = new int[4];
  4. if(splittedString.length == 4) {
  5. int i = 0;
  6. for(String elements : splittedString) {
  7. tempArray[i] = Integer.parseInt(elements);
  8. i++;
  9. }
  10. } else {
  11. throw new IPFormatException(string);
  12. }
  13. return new IPAddress(tempArray);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement