public static void main(String[] args) {
byte[] readBuffer = new byte[1024*1024];
try {
String flightInfo=new String(readBuffer,"UTF-8");
int length=flightInfo.length();
System.out.println(length);
flightInfo=flightInfo.trim();//通过trim去掉空字符
int length2=flightInfo.length();
System.out.println(length2);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
结果: