@Test public void testWrapOnSingleLine() { byte[] b = new byte[8]; for (int i = 0; i < b.length; i++) b[i] = (byte) i; String expected = "0001020304050607\r\n"; assertEquals(expected, AsciiArmour.wrap(b, 70)); }
static String wrap(byte[] b, int lineLength) { String wrapped = StringUtils.toHexString(b); StringBuilder s = new StringBuilder(); int length = wrapped.length(); for (int i = 0; i < length; i += lineLength) { int end = Math.min(i + lineLength, length); s.append(wrapped.substring(i, end)); s.append("\r\n"); } return s.toString(); }
AsciiArmour { static String wrap(byte[] b, int lineLength) { String wrapped = StringUtils.toHexString(b); StringBuilder s = new StringBuilder(); int length = wrapped.length(); for (int i = 0; i < length; i += lineLength) { int end = Math.min(i + lineLength, length); s.append(wrapped.substring(i, end)); s.append("\r\n"); } return s.toString(); } }
AsciiArmour { static String wrap(byte[] b, int lineLength) { String wrapped = StringUtils.toHexString(b); StringBuilder s = new StringBuilder(); int length = wrapped.length(); for (int i = 0; i < length; i += lineLength) { int end = Math.min(i + lineLength, length); s.append(wrapped.substring(i, end)); s.append("\r\n"); } return s.toString(); }  }
AsciiArmour { static String wrap(byte[] b, int lineLength) { String wrapped = StringUtils.toHexString(b); StringBuilder s = new StringBuilder(); int length = wrapped.length(); for (int i = 0; i < length; i += lineLength) { int end = Math.min(i + lineLength, length); s.append(wrapped.substring(i, end)); s.append("\r\n"); } return s.toString(); }   }
AsciiArmour { static String wrap(byte[] b, int lineLength) { String wrapped = StringUtils.toHexString(b); StringBuilder s = new StringBuilder(); int length = wrapped.length(); for (int i = 0; i < length; i += lineLength) { int end = Math.min(i + lineLength, length); s.append(wrapped.substring(i, end)); s.append("\r\n"); } return s.toString(); }    }