I have the method like below to read the file:
String[] readFile(String file) throws IOException {
String[] contentFile;
BufferedReader br = new BufferedReader(new FileReader(path + file + ".txt"));
try {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (true) {
sb.append(line);
// sb.append(System.lineSeparator());
line = br.readLine();
if (line == null) {
break;
}
....
But when the file in FileReader does not - exists there is an exception. How to create the file before initializang BufferedReader if it does not exists in the above case?