Hi Guys,
Im trying to run an unix command from my application, Basically I want to extract a tar file, but Im getting an I/O exception while running the below code. Can you please tell me as to how this has to be done //////////////////////////// executeCommand("tar", "- xvf", pathOfFileToBeExtracted); /////////////////////////// public static void executeCommand(String command, String arg0, String arg1) throws Exception { try { Class execClass = Class.forName("android.os.Exec"); Method createSubprocess = execClass.getMethod("createSubprocess", String.class, String.class, String.class, int[].class); Method waitFor = execClass.getMethod("waitFor", int.class); int[] id = new int[1]; FileDescriptor fileDescriptor = (FileDescriptor) createSubprocess.invoke( null, command, arg0, arg1, id); FileInputStream inputStream = new FileInputStream(fileDescriptor); BufferedReader reader = new BufferedReader(new InputStreamReader (inputStream)); String output = ""; String line; while ((line = reader.readLine()) != null) { output += line + "\n"; } waitFor.invoke(null, id[0]); } catch (Exception e) { System.out.println(e); throw new Exception(); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---