我真的不知道,为什么这对于读取包含很多类的文件来说如此复杂和困难
- 输入流
- 数据输入流
- 输入流
- 缓冲区读取器
下面有什么好处?这里的哲学是什么?
private static String fileToString(String filename) throws IOException
{
InputStream resourceAsStream;
resourceAsStream = "".getClass().getResourceAsStream(filename);
DataInputStream in = new DataInputStream(resourceAsStream);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder builder = new StringBuilder();
String line;
// For every line in the file, append it to the string builder
while((line = reader.readLine()) != null)
{
builder.append(line);
}
return builder.toString();
}