添加2个字符串到文件和字符串大小

时间:2017-08-06 12:59:03

标签: java server stringbuilder

我是从服务器读取的,这是在文件和字符串的长度上加2?

StringBuilder sb = new StringBuilder();

System.out.print("post first read ");
File temp = new File("temp.html");
FileWriter fileWriter = new FileWriter(temp);
//write string to file 
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

while ((nread = reader.read()) != -1) {
    System.out.println("post while read " + nread);
    inread = (char) nread;
    bufferedWriter.append(inread);
    sb.append(inread);
}

byteString = sb.toString();

1 个答案:

答案 0 :(得分:-1)

也许是" \ n" (换行符)添加到字符串的末尾,最好使用reader.readLine()而不是reader.read()

我知道这应该是一个评论,但......声誉不够:(