how to get a byte[] representation from a IP in String form in Java
Each number is a byte, so in your case the appropriate byte[] would be { 192, 168, 2, 1 }.
To be more specific, if you have the string, you first have to split it by the "."s and then parse a byte from each resulting string.
Something like this:
InetAddress ip = InetAddress.getByName("192.168.2.1");
byte[] bytes = ip.getAddress();
for (byte b : bytes) {
System.out.println(b & 0xFF);
}