public byte[] convert(String javaFile) throws JadxException {
ByteArrayOutputStream errOut = new ByteArrayOutputStream();
try {
DxConsole.err = new PrintStream(errOut, true, CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new JadxException(e.getMessage(), e);
}
PrintStream oldOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(baos, true, CHARSET_NAME));
DxArgs args = new DxArgs("-", new String[]{javaFile});
Main.run(args);
baos.close();
} catch (Throwable e) {
throw new JadxException("dx exception: " + e.getMessage(), e);
} finally {
System.setOut(oldOut);
}
try {
// errOut also contains warnings
dxErrors = errOut.toString(CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
throw new JadxException("Can't save error output", e);
}
return baos.toByteArray();
}