public static String encodeInt2HexString(int value, int length, boolean littleEndian) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < length; i++) {
      int oneByte = value & 0xFF;
      if (littleEndian) {
        sb.append(Hex.byte2Hex(oneByte));
      } else {
        sb.insert(0, Hex.byte2Hex(oneByte));
      }
      value = value >> 8;
    }
    return sb.toString();
  }
Provide test use functions for JfifUtilTest.
imagepipeline-base/src/test/java/com/facebook/imageutils/JfifTestUtils.java