Results 1 to 6 of 6
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default checking valid IP method

    I have this method in my class:

    Java Code:
    public static void IPCheck(String IP) {
    	            boolean inet = isInetAddress(IP);
    	    }
    I am getting this error message:
    Java Code:
    The method isInetAddress(String) is undefined for the type port

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: checking valid IP method

    First off, that suggests that you have a class named port -- which is a violation of the Java coding conventions. A class name should begin with an uppercase letter.

    Apart from that, the error message is pretty clear: in the port class, which is where you have the method posted, there isn't a method named isNetAddress(...) that accepts a String parameter.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: checking valid IP method

    but I have imported this:
    Java Code:
    import java.net.*;
    InetAddress (Java Platform SE 6)

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: checking valid IP method

    There's no method isInetAddress(String) in InetAddress, either. If you want that method to exist, you'll have to write it yourself.

    And even if it did exist, the code in your original post is completely pointless. You're assigning a value to a local variable that will disappear when the method exits, and not taking any action based on its value.
    Get in the habit of using standard Java naming conventions!

  5. #5
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: checking valid IP method

    so what is the best way to check for a valid IP address? I read that there is an apache method for it. is this possible?

  6. #6
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: checking valid IP method

    Is it possible that there is a method to do it in one of the Apache libraries? Sure, I guess...

    How would you, as a human being looking at it, decide if something was a valid IP address? Answer that and then it's a simple matter to translate it into code.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Replies: 1
    Last Post: 05-08-2013, 07:19 PM
  2. Valid input
    By Dex in forum New To Java
    Replies: 1
    Last Post: 09-30-2012, 02:19 PM
  3. Checking if a math function is valid
    By HardToHandle in forum New To Java
    Replies: 3
    Last Post: 01-18-2012, 01:40 AM
  4. Replies: 15
    Last Post: 09-29-2008, 07:18 AM
  5. Valid declarations
    By heat84 in forum New To Java
    Replies: 1
    Last Post: 12-22-2007, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •