@Test public void byteBufferToString() { class TestCase { String mExpected; ByteBuffer mInput; public TestCase(String expected, ByteBuffer input) { mExpected = expected; mInput = input; } } List<TestCase> testCases = new ArrayList<>(); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {}))); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {0}))); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {0, 0}))); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {0, 0, 0}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0, 0}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0, 0, 0}))); testCases.add(new TestCase("1 2", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0, 0, 0, 2}))); for (TestCase testCase : testCases) { assertEquals(testCase.mExpected, FormatUtils.byteBufferToString(testCase.mInput)); } }
public static String byteBufferToString(ByteBuffer buf) { StringBuilder sb = new StringBuilder(); for (int k = 0; k < buf.limit() / 4; k++) { if (k != 0) { sb.append(" "); } sb.append(buf.getInt()); } return sb.toString(); }
FormatUtils { public static String byteBufferToString(ByteBuffer buf) { StringBuilder sb = new StringBuilder(); for (int k = 0; k < buf.limit() / 4; k++) { if (k != 0) { sb.append(" "); } sb.append(buf.getInt()); } return sb.toString(); } }
FormatUtils { public static String byteBufferToString(ByteBuffer buf) { StringBuilder sb = new StringBuilder(); for (int k = 0; k < buf.limit() / 4; k++) { if (k != 0) { sb.append(" "); } sb.append(buf.getInt()); } return sb.toString(); } private  FormatUtils(); }
FormatUtils { public static String byteBufferToString(ByteBuffer buf) { StringBuilder sb = new StringBuilder(); for (int k = 0; k < buf.limit() / 4; k++) { if (k != 0) { sb.append(" "); } sb.append(buf.getInt()); } return sb.toString(); } private  FormatUtils(); static String parametersToString(Object... objs); static String byteBufferToString(ByteBuffer buf); static String byteArrayToHexString(byte[] bytes); static String byteArrayToHexString(byte[] bytes, String prefix, String separator); static String formatTimeTakenMs(long startTimeMs, String message); static String formatTimeTakenNs(long startTimeNs, String message); static String getSizeFromBytes(long bytes); static long parseSpaceSize(String spaceSize); static long parseTimeSize(String timeSize); static String formatMode(short mode, boolean directory, boolean hasExtended); }
FormatUtils { public static String byteBufferToString(ByteBuffer buf) { StringBuilder sb = new StringBuilder(); for (int k = 0; k < buf.limit() / 4; k++) { if (k != 0) { sb.append(" "); } sb.append(buf.getInt()); } return sb.toString(); } private  FormatUtils(); static String parametersToString(Object... objs); static String byteBufferToString(ByteBuffer buf); static String byteArrayToHexString(byte[] bytes); static String byteArrayToHexString(byte[] bytes, String prefix, String separator); static String formatTimeTakenMs(long startTimeMs, String message); static String formatTimeTakenNs(long startTimeNs, String message); static String getSizeFromBytes(long bytes); static long parseSpaceSize(String spaceSize); static long parseTimeSize(String timeSize); static String formatMode(short mode, boolean directory, boolean hasExtended);  }