1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-08 08:23:11 +00:00

Change-Id: Ie09760fc3cc7b8d2cae93aa433e1e2cf684c8ae3

This commit is contained in:
rogiel
2011-04-30 07:54:49 -03:00
parent f454e3c35a
commit 8984654ed5
12 changed files with 237 additions and 189 deletions

View File

@@ -0,0 +1,24 @@
package com.l2jserver.util;
import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
public class BufferUtil {
public static final String readString(ChannelBuffer buffer) {
char[] str = new char[buffer.readableBytes()];
int index = 0;
char c;
while ((c = buffer.readChar()) != 0) {
str[index++] = c;
}
return String.valueOf(Arrays.copyOfRange(str, 0, index));
}
public static final void writeString(ChannelBuffer buffer, String str) {
for (char c : str.toCharArray()) {
buffer.writeChar(c);
}
buffer.writeChar(0x00);
}
}