有没有办法一次性将 BufferedReader 放入字符串中,而不是逐行放置?这是我到目前为止所拥有的:
BufferedReader reader = null;
try
{
reader = read(filepath);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
String line = null;
String feed = null;
try
{
line = reader.readLine();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
while (line != null)
{
//System.out.println(line);
try
{
line = reader.readLine();
feed += line;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println(feed);
最佳答案
你可以使用 Apache FileUtils图书馆。
关于java - 如何将 BufferedReader 的内容放入字符串中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9849448/