Android Studio 3.0
classpath 'com.android.tools.build:gradle:3.0.0'
In official documentaion https://developer.android.com/studio/write/java8-support.html#supported_features
I read the next:
"In addition to the Java 8 language features and APIs above, Android Studio 3.0 and later extends support for try-with-resources to all Android API levels."
OK. And here my snippet:
public static boolean writeToDir(File path, String fileName, InputStream inputStream) {
try (FileOutputStream fileOutputStream = new FileOutputStream(new File(path, fileName))) {
byte[] bytes = IOUtils.toByteArray(inputStream);
fileOutputStream.write(bytes);
return true;
} catch (Exception e) {
return false;
}
}
And I get compile error:
Try-with-resources requires API level 19 (current min is 15)
Why?
In officail documentation write:
"... try-with-resources to ALL Android API levels"