I need to read text file to String. I do :
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(filePath));
String line = br.readLine();
String everything = line;
while (line != null) {
line = br.readLine();
everything += line + "\n";
}
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
if (br != null)
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
But I dont like to read line by line. It should be possible to read whole file to string at one function call. I'm right? By the way, I must use java 1.4.