From c5a0b629b9d5b62b514470e9f85a319638b78e86 Mon Sep 17 00:00:00 2001 From: RedKale <22250530@qq.com> Date: Mon, 6 Jun 2016 21:12:17 +0800 Subject: [PATCH] --- src/org/redkale/util/Utility.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/org/redkale/util/Utility.java b/src/org/redkale/util/Utility.java index 109820b07..0b6c45e95 100644 --- a/src/org/redkale/util/Utility.java +++ b/src/org/redkale/util/Utility.java @@ -88,18 +88,24 @@ public final class Utility { public static String toString(String string, ByteBuffer buffer) { if (buffer == null || !buffer.hasRemaining()) return string; + int pos = buffer.position(); + int limit = buffer.limit(); byte[] bytes = new byte[buffer.remaining()]; buffer.get(bytes); - buffer.flip(); + buffer.position(pos); + buffer.limit(limit); if (string == null) return new String(bytes, UTF_8); return string + new String(bytes, UTF_8); } public static void println(String string, ByteBuffer buffer) { if (buffer == null || !buffer.hasRemaining()) return; + int pos = buffer.position(); + int limit = buffer.limit(); byte[] bytes = new byte[buffer.remaining()]; - buffer.get(bytes); - buffer.flip(); + buffer.get(bytes); + buffer.position(pos); + buffer.limit(limit); println(string, bytes); }