Thansk, Akshath.
I have done this:
//get byte array with my values
byte image[] = (byte[])classX.GetByteArrayValues();
//convert byte array to char array, so all the values will be positive 0...255
char imageCh[] = new char[image.length];
for (int ij = 0; ij < image.length; ij++)
{
imageCh[ij] = (char) image[ij];
if (imageCh[ij] > 255)
imageCh[ij] &= 0xFF;
}
//set DataMode to BYTE
clientH.setDataMode(DataMode.BYTE, DataType.OUT);
//convert char array to string
String b = new String(imageCh);
//send string with sendClientBytes
clientH.sendClientBytes(b);
However, the result in the receiving application is the same (negative values are 2 bytes). I am starting to think it's a problem of the receiving application where I first read the input stream into a string with NSASCIIStringEncoding and then when I want to retrieve the byte portion of this string where my data payload is located, I read the bytes from the string with NSUTF8StringEncoding. As I just realized this encoding is variable in width so that could explain why values of 128-255 are represented by two bytes.