I want to send a byte Array of 256 byte length, it have to be 128 byte of a string and the same length with another string ( lengths are just for testing purposes).
This is my code:
public void packetCompose(String user, String password) {
//insert user in 128 bytes length, same with password
//and make a 256 length byte array to send
byte[] userBytes = user.getBytes();
byte[] passwordBytes = password.getBytes();
byte[] buf = new byte[256];
}
I want to userBytes be 128 bytes length, even if there are more bytes than needed, and the same with passwordBytes. Then make buf be like userBytes followed by passwordBytes.
Any suggestions? thanks in advance
Just copy the bytes into the destination
bufarray.