try {
Runtime runByRoot = Runtime.getRuntime().exec("su -c \"cp -r /data/data/com.kakao.talk/databases /storage/emulated/0/database\"");
//BufferedReader reader = new BufferedReader(new InputStreamReader(getRoot3.getInputStream()));
runByRoot.waitFor();
File getFilePath = new File("/storage/emulated/0/database");
File[] filesList = getFilePath.listFiles();
for(i : filesList) {
replier.reply(filesList[i]);
}; replier.reply ("executed");
} } catch(err) {
replier.reply(err);
};
//replier.reply method is a method that outputs a factor value. You can ignore it!
It's a source that I made because I wanted to copy the directory, but I don't think there's an error or a mistake, but in conclusion, the file is not copied. Just in case I typed it wrong, I copied and copied the command part and executed it at the terminal, but it works well at the terminal...
java
String test_cmd[] = new String[] {"test.sh", "1", "test"};
ProcessBuilder test_pb = new ProcessBuilder(test_cmd);
Process test_p = test_pb.start();
int signal = test_p.waitFor();
When performing a Java terminal command, try separating it into a string array as shown above, not one string. You can separate them by spacing.
I looked it up when I was working on it, and I saw that it doesn't work properly if you use one string. It didn't work out in real life, so I used it as a string arrangement.
If that doesn't work, check the output using getInputStream() or
getErrorStream()
in Process
after the waitFor() call.
There was a problem that I couldn't recognize the |
in the command, and it didn't work as I thought.
© 2024 OneMinuteCode. All rights reserved.