I'm trying to get the output of a process that executes a binary file like this:
Runtime rt = Runtime.getRuntime();
String[] command = new String[]{this.binaryPath, text};
Process p = rt.exec(command);
Scanner s = new Scanner(p.getInputStream()).useDelimiter("\\A");
String output = s.hasNext() ? s.next() : "";
However when I build my project with Gradle, I get an error saying:
Task :forbiddenApisMain FAILED Forbidden method invocation: java.util.Scanner#(java.io.InputStream) [Uses default charset]
Apparently something I'm doing is forbidden by Gradle. What is it and what are my alternatives here so Gradle doesn't complain?