File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes how can i validate the ip address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how can i validate the ip address" Watch "how can i validate the ip address" New topic

how can i validate the ip address

ajay verma
Ranch Hand

Joined: Dec 10, 2007
Posts: 37
how can i validate the ip address.example are given below is invalid is invalid is invaid

hint: with the help of String tokenize()
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

First of all, and are perfectly valid. Just because they have an extra 0 doesn't mean they aren't valid. is equal to

Second, use String.split instead, using "\\." as the regex. The \\ will be resolved to a single \ for the regex, which is used to escape the .

How To Ask Questions How To Answer Questions
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
give it a try,
if you need help, let us know,
post the code,

Bill Shirley - bshirley -
if (Posts < 30) JavaRanchFAQ);
I agree. Here's the link:
subject: how can i validate the ip address
It's not a secret anymore!