开发者

BufferedReader.readLine() cuts off beginning of the line

开发者 https://www.devze.com 2023-03-25 08:53 出处:网络
I have a problem with reading a file. BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream(file), \"UTF-8\"));

I have a problem with reading a file.

BufferedReader in = new BufferedReader(
                      new InputStreamReader(
                         new FileInputStream(file), "UTF-8"));
while ((line = in.readLine()) != null) {
   parseLine(line);
}

Trouble causing line:
 a:38:{s:10:"aaaaaaaaaa";s:6:"215302";s:4:"bbbb";s:9:"新村莊";s:10:"cccccccccc";s:6:"330345";s:6:"dddddd";s:3:"-68";s:6:"eeeeee";s:3:"-12";s:9:"fffffffff";s:4:"3470";s:7:"ggggggg";s:1:"3";s:10:"hhhhhhhhhh";s:1:"2";s:7:"iiiiiii";s:3:"391";s:11:"jjjjjjjjjjj";s:1:"2开发者_Go百科";s:15:"jjjjjjjjjjjjjjj";s:1:"8";s:15:"jjjjjjjjjjjjjjj";s:1:"8";s:15:"jjjjjjjjjjjjjjj";s:1:"8";s:16:"jjjjjjjjjjjjjjjj";s:2:"12";s:14:"jjjjjjjjjjjjjj";N;s:11:"jjjjjjjjjjj";N;s:13:"jjjjjjjjjjjjj";N;s:20:"jjjjjjjjjjjjjjjjjjjj";s:1:"1"... etc

At about the 30th file in row about 105000, readline() cuts off the first 69 characters. The line has a total of 936 characters.

Any idea why readline() cuts off the characters? (BTW, there are lines that are longer!)


I tried your code but with a simple System.out.println(line) where you call the parseLine(line) method and everything works fine: your sample trouble causing line appears correct in my console.

Please try yourself and let us see your parseLine(line) method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号