Mercurial > stress-tester
changeset 685:25d4e7b3722e
NcDataHelper
author | Devel 1 |
---|---|
date | Fri, 24 Nov 2017 14:11:55 +0100 |
parents | 2f43e5c1f20d |
children | 3abf8dd75b09 |
files | stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Thu Nov 23 14:39:08 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Fri Nov 24 14:11:55 2017 +0100 @@ -268,6 +268,18 @@ throw new IllegalArgumentException("Unable to find NULL delimiter."); } + public int writeStringNullTerminated(String value, ByteBuff buffer) { + if (value != null && !value.isEmpty()) { + byte[] data = value.getBytes(CHARSET); + buffer.append(data); + buffer.append(AsciiUtils.NUL); + return data.length + 1; + } + + buffer.append(AsciiUtils.NUL); + return 1; + } + public int writeStringNullTerminated(String value, ByteBuffer buffer) { if (value != null && !value.isEmpty()) { byte[] data = value.getBytes(CHARSET);