从DataInput读取固定字符串
//package com.nowjava; import java.io.*; /* from nowjava.com - 时代Java*/ public class Main { public static String readFixedString(DataInput in, int length) throws IOException { StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { char c = in.readChar(); //if char is not Unicode zero add if (c != 0) sb.append(c); } return sb.toString(); } }