I have a problem with "try-with-resources are not supported at this language level" in android in the following posted code, I tried to set language to 7 but it stills keeps giving me the same example plus it keeps giving me the option to change to language 7.
public String ReadFile(String fileName) {
try (BufferedReader br = new BufferedReader(new FileReader(fileName+".txt"))) {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.lineSeparator());
line = br.readLine();
}
String everything = sb.toString();
return everything;
} catch (FileNotFoundException ex) {
Logger.getLogger(SaveNLoadRank.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(SaveNLoadRank.class.getName()).log(Level.SEVERE, null, ex);
}
return "1";
}
Try-with-resources requires minSdkVersion 19
– Hokkaido