Why is my BufferedReader reading text that dosn't exit in the given file?

后端 未结 3 570
渐次进展
渐次进展 2021-01-25 23:06

I am using a BufferedReader to read details from a file which are stored as bytes, I am then converting the bytes into text and splitting it into an

3条回答
  •  清歌不尽
    2021-01-25 23:48

    Follow this code:
    
            String lineFromFile = bufferedReader.readLine();
            // strip out the `[` and `]`
            lineFromFile = lineFromFile.substring(1, lineFromFile.length()-1);
            StringBuilder sb = new StringBuilder();
            for(String s: lineFromFile.split(", "))
                sb.append((char) Integer.parseInt(s));
            String text = sb.toString();
    

提交回复
热议问题