Пример #1
0
 /**
  * Adds a String to the data. The String is broken up into its component chars and each is written
  * to the data.
  *
  * @param value The String to write.
  * @param characterWidth The width in bytes of each character.
  * @param withSeparator If this is true, a null separator is added to the end of the String in the
  *     data.
  */
 public void composeString(String value, int characterWidth, boolean withSeparator) {
   char[] stringChars = value.toCharArray();
   byte[] characterBytes = new byte[characterWidth];
   ByteHolder stringBytes = new ByteHolder(stringChars.length * characterWidth);
   for (char c : stringChars) {
     characterBytes = charToBytes(c, characterWidth);
     stringBytes.add(characterBytes);
   }
   composeBytes(stringBytes.toArray());
   if (withSeparator) {
     composeBytes(makeNullSeparator(characterWidth));
   }
 }
Пример #2
0
 /**
  * Adds an int to the data with a specified width.
  *
  * @param value The int to add.
  * @param width The width of the int.
  */
 public void composeInt(int value, int width) {
   composeBytes(intToBytes(value, width));
 }