### Question:
JCAChannelHandler extends MultiplexedChannelHandler<JCAConnectionPayload, JCAMessagePayload> { static String toString(byte[] data) { int index = 0; while (index < data.length && data[index] != '\0') { index++; } return new String(data, 0, index); } JCAChannelHandler(String channelName, JCADataSource jcaDataSource); boolean isPutCallback(); boolean isLongString(); JCADataSource getJcaDataSource(); String getJcaChannelName(); @Override synchronized void connect(); @Override synchronized void disconnect(); @Override void write(Object newValue, final ChannelWriteCallback callback); @Override synchronized Map<String, Object> getProperties(); static Pattern longStringPattern; }### Answer:
@Test public void toString1() { byte[] test = new byte[] {97,98,99,0,100}; String result = JCAChannelHandler.toString(test); assertThat(result, equalTo("abc")); }
@Test public void toString2() { byte[] test = new byte[] {97,98,99,100}; String result = JCAChannelHandler.toString(test); assertThat(result, equalTo("abcd")); }