Java code for validating ip address

The source code is compiled and tested in my dev environment.

I am writing a program to read in data from an excel sheet which contains a bunch of info about computers which will be entered by the user.

Assuming there is no built-in function that validates only IP Addresses, I've come up with this not so great solution to validate that the string fits a very general description of an IP Address: Thanks.

I would have thought with all the classes & functions already in Java that they'd have one that specifically does this, but your function looks like it should work just fine.

Depending on the source of the input, the validation function might pose a huge performance risk and cause OM (out of memory) errors.

See, even really short strings of just dots create one String object per character.

The Java Script Source: Forms: Validation (IP Address) Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s).

Correcting wrong assumptions happens all the time on Stack Exchange sites. Your code has three major errors that all the previous reviewers failed to spot.

If I were a lecturer, I'd show your code to the students as an example why they should always use libraries, even doing something seemingly simple as validating the IPv4 address. Besides that, we are starting to make the migration to the IPv6 standard, which is harder to validate.

So, if you can rely on a well tested library for IP validation that does not bring an additional huge dependency to your code, use that instead.

Is there any function that will only take IP Addresses?

I'm trying to validate an IP Address that I'm passing to an API that only says it accepts IP Addresses, so I don't want DNS names to get through.

Search for java code for validating ip address:

java code for validating ip address-7

Stack Exchange network consists of 171 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “java code for validating ip address”

  1. online casino games guide spilleautomat The Flash Velocity Forden Det siste innen grafikk vil forbedre din spillopplevelse dramatisk helersom du er norsk, svensk eller finsk, vel.

  2. If someone is critical of you (and you know you’re at fault), you’ll either own up to it or tell them exactly what they want to hear to stop the fighting ASAP.