FIXTags { public static void put(ByteBuffer buffer, int tag) { if (tag < 1 || tag > 99999) tooLargeTag(); byte b1 = (byte)('0' + tag % 10); tag /= 10; if (tag != 0) { byte b2 = (byte)('0' + tag % 10); tag /= 10; if (tag != 0) { byte b3 = (byte)('0' + tag % 10); tag /= 10; if (tag != 0) { byte b4 = (byte)('0' + tag % 10); tag /= 10; if (tag != 0) { byte b5 = (byte)('0' + tag % 10); buffer.put(b5); } buffer.put(b4); } buffer.put(b3); } buffer.put(b2); } buffer.put(b1); buffer.put(EQUALS); } private  FIXTags(); static int get(ByteBuffer buffer); static void put(ByteBuffer buffer, int tag);  }
@Test public void put() { ByteBuffer buffer = ByteBuffer.allocateDirect(4); FIXTags.put(buffer, 123); buffer.flip(); assertEquals("123=", ByteBuffers.getString(buffer)); }