473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to enter a string Ip address to an inetAddress class?

Hi,

I am having a swings application which reads the ip address in the string format and need to validate the ip address is of ip4 or ip6 format and process the ipaddress.
I have seen the inetAddress class but that requires the input to be in byte array.
But if the user enters the ip in IP6 format i need to make the string to an array of size 16. This manipulation if any one can please help me out?

Shashi.
Aug 31 '07 #1
1 4167
JosAH
11,448 Expert 8TB
Hi,

I am having a swings application which reads the ip address in the string format and need to validate the ip address is of ip4 or ip6 format and process the ipaddress.
I have seen the inetAddress class but that requires the input to be in byte array.
But if the user enters the ip in IP6 format i need to make the string to an array of size 16. This manipulation if any one can please help me out?

Shashi.
The InetAddress class has static methods that simply take a String representation
of either the host name or the IP address (whether it be IP/4 or IP/6; check the API
documentation).

kind regards,

Jos
Aug 31 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: crypto_stonelock | last post by:
Hello, I was wondering if anybody knew how to retrieve the IP address attributed dynamically by your ISP without having to use the info collected on a socket with say .getLocalAddress. I'm...
7
by: gurtd_dauberie | last post by:
I can't get the correct IP address on Linux... The following code works properly on Windows and Unix. But on Linux, I always get the Loopback Address (127.0.0.1) Here is the code : //gets the...
4
by: Arne | last post by:
Hi, Probably an easy answer to this, but I have not been able to figure it out. How can I find the IP-address of the machine that my Java-program is running on ? Could not find any methods in...
1
by: jseidelREMOVECAPS | last post by:
I need to create a socket connection to a site. String name = "elektra.usm.com" socket sock = new socket( name, port ); This wont work because the name isn't an ip address. I need to create...
3
by: Lowell Kirsh | last post by:
I want to create a link that a user can click which will create a popup telling the user their ip address. I have: var ip = new java.net.InetAddress.getLocalHost().toString(); alert("Your IP...
2
by: James Bond 007 | last post by:
I want to extract the user's IP address and put it into my form without him/her knowing about it. I have Javascript code (see below) to get the user's "start time", which works just fine (i.e.,...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
1
by: opmbmit | last post by:
i want to write acode in java so that i can get the ip address of localhost or remote host using system call. i know that threre is inetAddress class exist to get it but do not want to use this...
1
by: thesti | last post by:
hello, i'm developing a J2SE VoIP app. i used the InetAddress.getLocalHost() to get the address of the local machine. it works in xp, but not in Ubuntu. in Ubuntu it gives me "127.0.1.1", which...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.