Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4339126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:10:29+00:00 2026-05-21T11:10:29+00:00

I am trying to convert an address specified by an IP number or a

  • 0

I am trying to convert an address specified by an IP number or a name, both in String (i.e. localhost or 127.0.0.1), into an InetAdress object. There’s no constructor but rather static methods that return an InetAddress. So if I get a host name it’s not a problem, but what if I get the IP number? There’s one method that gets byte[] but I’m not sure how that can help me. All other methods gets the host name.

InetAddress API documentation

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:10:30+00:00Added an answer on May 21, 2026 at 11:10 am

    You should be able to use getByName or getByAddress.

    The host name can either be a machine
    name, such as “java.sun.com”, or a
    textual representation of its IP
    address

    InetAddress addr = InetAddress.getByName("127.0.0.1");
    

    The method that takes a byte array can be used like this:

    byte[] ipAddr = new byte[]{127, 0, 0, 1};
    InetAddress addr = InetAddress.getByAddress(ipAddr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to convert a VB6 program into C#. There was extensive
I am trying to convert an object into JSON using the GSON library on
I'm trying to convert the distinguishedName of a Domain into the address for the
i'm new to mod_rewrite, and i'm trying to convert my web address from: website.com/profile.php?user=andy
Trying to convert this c code into MIPS and run it in SPIM. int
Trying to convert int arrays to string arrays in numpy In [66]: a=array([0,33,4444522]) In
Hello I'm trying to convert youtube links into embed code. this is what I
I'm trying to convert IP address to MAC address and then convert it to
As part of a larger application, I am trying to convert an IP address
I'm trying to write some code that will take any object and convert it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.