We help IT Professionals succeed at work.

Convert Java String into a Byte Array

nothing8171
nothing8171 asked
on
Medium Priority
1,477 Views
Last Modified: 2008-02-01
Hello folks,

I have a String containing an IP address.  Ex. String ip = "192.168.10.1" and I need this turned into a byte array.

bytear[0] = 192;
bytear[1] = 168;
bytear[2] = 10;
bytear[3] = 1;

The periods in the ip address are what's getting me.  Suggestions?

Thanks
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016
Commented:

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
rrzstudent
CERTIFIED EXPERT
Commented:
>The periods in the ip address are what's getting me.  Suggestions    
String[] a = ip.split("\\.");
CERTIFIED EXPERT
Top Expert 2016

Commented:
:-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.