Convert Java String into a Byte Array

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
LVL 1
nothing8171Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
rrzConnect With a Mentor Commented:
>The periods in the ip address are what's getting me.  Suggestions    
String[] a = ip.split("\\.");
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.