Спасибо за отзывы! Помощь переоценивается сегодня ...
Пока что я нашел решение и публикую метод:
private String pack(int value, int allocateBytes, ByteOrder byteOrder, String charsetName) throws UnsupportedEncodingException {
ByteBuffer buf = ByteBuffer.allocate(allocateBytes);
buf.order(byteOrder);
byte[] bytes = buf.putInt(value).array();
String result = new String(bytes, charsetName);
return result;
}
Например, вызов пакета ('L') для Ruby / PHP можно имитировать, вызывая метод Java следующим образом:
pack(myString.getBytes().length, 4, ByteOrder.LITTLE_ENDIAN, "UTF-8");