亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java8 - java.nio.charset.MalformedInputException: Input length = 2
大家講道理
大家講道理 2017-04-18 10:45:13
0
2
1578
大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(2)
小葫蘆
public static void main(String[] args) throws IOException {
        File file = new File("/home/yangxiaohuan/Documents/TokenizeThenSplitParallelDeletePatternLTZero.txt");
        InputStreamReader read = new InputStreamReader(new FileInputStream(file), "UTF-8");// 考慮到編碼格式
        BufferedReader br = new BufferedReader(read);
        int cnt=0;
        while(br.ready()){
            String text = br.readLine();
            cnt++;
            if(cnt>=47334){
                System.out.println(text);
                }
            System.out.println("cnt = "+cnt);
            }
        }
}

The original code needs to import the following classes
import java.nio.file.Files;
import java.nio.file.Paths;
But change it to this form
import java.io.File;
import java.io. FileInputStream;
is normal and there is no error.
And some friends said that if you delete one character from the original text and the line with the error, there will be no error. Very strange question. I don’t know why there is a problem using nio.file.Files

PHPzhong

Thanks for the invitation. You may have misunderstood the difference between IO and NIO. The most basic point is that IO is stream-oriented, and NIO is buffer-oriented. Your code obviously uses BufferedReader and InputStreamReader streams. If you use nio, readLine will not work at all. Cannot read, NIO can only read the buffer, scan the size of the buffer, and when parsing the data, NIO needs to pay a greater price than blocking the IO stream.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template