I stumbled upon this problem when trying to play around with Apache commons IO third party API with Android Studio.
Basically when I try to call the FileUtils.readLines() method, there are 3 options:
The first option has already been deprecated which means that I shouldn't use it anymore so instead I just type readLines(file,null) However, right now the problem is that Android Studio doesn't know which readLines() method signature I'm using because readLines(file,null) is valid for both the second and third method signature.
Screenshot below to further explain what I mean:
Can anyone please enlighten me on this? How can I tell Android Studio the particular method signature that I want to use for FileUtils.readLines()?
IDE can't guess what your null is. Whether it is String or Charset. You can try something like:
String encoding=null;
FileUtils.readLines(file, encoding);
But I think that wouldn't work since readLines
method needs to know what encoding your file uses. So if for example your file uses UTF-8, you can write this
FileUtils.readLines(file, StandardCharsets.UTF_8);
Or you can try to use default charset, see this: How to Find the Default Charset/Encoding in Java?
And as Apache docs say, deprecated version readLines(File file) used default charset. You can write this to get an equivalent:
FileUtils.readLines(file, Charset.defaultCharset());