Code example for FileWriter

Methods: close, write

0
    private static void bootCommand(Context context, String arg) throws IOException {
        RECOVERY_DIR.mkdirs();  // In case we need it
        COMMAND_FILE.delete();  // In case it's not writable
        LOG_FILE.delete();
 
        FileWriter command = new FileWriter(COMMAND_FILE);
        try { 
            command.write(arg);
            command.write("\n");
        } finally { 
            command.close();
        } 
 
        // Having written the command file, go ahead and reboot 
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        try { 
        	Method reboot = pm.getClass().getMethod("recovery", String.class);
        	reboot.invoke(pm, "recovery");
        } 
        catch (Exception e) {
        	throw new RuntimeException("Reboot failed", e);