当前位置: 代码迷 >> J2EE >> Java IO 字节流计数有关问题
  详细解决方案

Java IO 字节流计数有关问题

热度:27   发布时间:2016-04-22 00:42:33.0
Java IO 字节流计数问题
Java code
InputStream in = new FileInputStream(file);BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));long count = 0;                String line = br.readLine();                while (line != null) {                    count += line.getBytes("UTF-8").length;                    count += 1;    // Add \r's length                    System.out.println(Thread.currentThread() + "  " + line);                    System.out.println(" count:" + count);                    line = br.readLine();                }


求问为什么count计算的字节数和实际的字节数不一样

------解决方案--------------------
Java code
InputStream in = new FileInputStream(file);System.out.println(in.available());
  相关解决方案