Receive byte response
public static receventity Getretvo (byte[] data)
{
Bytebuffer buf = bytebuffer.wrap (data);
Buf.order (Constantself.agentmsgbyteset);
SELFQRYRSPVO Uvo = new SELFQRYRSPVO ();
{
byte[] cisdn = new BYTE[21];
Buf.get (CISDN);
UVO.SETISDN (New String (CISDN, constantself.agentmsgencoding). toString (). Trim ());
Uvo.setdwseq (Buf.getint ());
Uvo.setbuflen (Buf.getint ());
Uvo.setresult (Buf.getint ());
}
}
Package Send byte data
public static byte[] GetBytes (int msgflag, int type,string fileName)
{
Total length of message sent
int Msgtotallen = 4 +
1 +
256;
Bytebuffer buf = bytebuffer.allocate (Msgtotallen);
Set the byte order
Buf.order (Byteorder.little_endian);
Try
{
Buf.putint (Msgflag);
Buf.put ((byte) type);
byte[] Bmdn = new byte[256];
byte[] Smdn = filename.getbytes ("GBK");
System.arraycopy (SMDN, 0, BMDN, 0, smdn.length);
Buf.put (BMDN);
}
catch (Exception ex)
{
Uniportal_logger.error (Ex.tostring ());
}
return Buf.array ();
}
Printing as a 16-input readable string
public static String Bytestohex (final byte[] bytes)
{
if (bytes = = null)
{
Return "";
}
StringBuffer strbuffer = new StringBuffer (Bytes.length * 3);
for (int i = 0;i < bytes.length;i++)
{
Strbuffer.append (Integer.tohexstring (bytes[i] & 0xff));
Strbuffer.append ("");
}
return strbuffer.tostring ();
}
Java Network Message interaction, typical parsing of a byte message in response: