Best way to build a String out of characters
This question already has an answer here:
你可以做类似的事情
public String readTextFile(File file) {
StringBuilder sb = new StringBuilder();
try(BufferedReader br = new BufferedReader(new FileReader(file))){
String line;
while ((line = br.readLine()) != null){
sb.append(line);
}
}
return sb.toString();
}
链接地址: http://www.djcxy.com/p/13744.html
下一篇: 从字符中构建字符串的最佳方法