@@ -0,0 +1,873 @@
+/**%0A * %0A */%0Apackage cn.strong.fastdfs.utils;%0A%0Aimport io.netty.buffer.ByteBuf;%0A%0Aimport java.nio.charset.Charset;%0A%0A/**%0A * %E5%B7%A5%E5%85%B7%E7%B1%BB%0A * %0A * @author liulongbiao%0A *%0A */%0Apublic class Utils %7B%0A%0A%09private Utils() %7B%0A%09%09super();%0A%09%7D%0A%0A%09/**%0A%09 * %E7%BB%99 ByteBuf %E5%86%99%E5%85%A5%E5%AE%9A%E9%95%BF%E5%AD%97%E7%AC%A6%E4%B8%B2%0A%09 * %3Cp%3E%0A%09 * %E8%8B%A5%E5%AD%97%E7%AC%A6%E4%B8%B2%E9%95%BF%E5%BA%A6%E5%A4%A7%E4%BA%8E%E5%AE%9A%E9%95%BF%EF%BC%8C%E5%88%99%E6%88%AA%E5%8F%96%E5%AE%9A%E9%95%BF%E5%AD%97%E8%8A%82%EF%BC%9B%E8%8B%A5%E5%B0%8F%E4%BA%8E%E5%AE%9A%E9%95%BF%EF%BC%8C%E5%88%99%E8%A1%A5%E9%9B%B6%0A%09 * %0A%09 * @param buf%0A%09 * @param content%0A%09 * @param length%0A%09 */%0A%09public static void writeFixLength(ByteBuf buf, String content, int length, Charset charset) %7B%0A%09%09byte%5B%5D bytes = content.getBytes(charset);%0A%09%09int blen = bytes.length;%0A%09%09int wlen = blen %3E length ? length : blen;%0A%09%09buf.writeBytes(bytes, 0, wlen);%0A%09%09if (wlen %3C length) %7B%0A%09%09%09buf.writeZero(length - wlen);%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * %E8%AF%BB%E5%8F%96%E5%9B%BA%E5%AE%9A%E9%95%BF%E5%BA%A6%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2(%E4%BF%AE%E5%89%AA%E6%8E%89%E8%A1%A5%E9%9B%B6%E7%9A%84%E5%AD%97%E8%8A%82)%0A%09 * %0A%09 * @param in%0A%09 * @param length%0A%09 * @return%0A%09 */%0A%09public static String readString(ByteBuf in, int length, Charset charset) %7B%0A%09%09return in.readBytes(length).toString(charset).trim();%0A%09%7D%0A%7D%0A

add Utils