Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    public static void chmod(String filename, int permissions) {
        Class<?> fileUtils = null;
        try {
            fileUtils = Class.forName("android.os.FileUtils");
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }
        Method setPermissions = null;
        int a;
        try {
            setPermissions = fileUtils.getMethod("setPermissions",
                    new Class[] { String.class, int.class, int.class, int.class });
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

        try {
            a = (Integer) setPermissions.invoke(null, filename, permissions, -1, -1);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}