创建不同权限的文件 openfileoutput

public void privateClick(View v) {
        try {
            FileOutputStream openFileOutput = openFileOutput("private.txt",
                    MODE_PRIVATE);
            openFileOutput.write("private".getBytes());
            openFileOutput.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void writeClick(View v) {
        try {
            FileOutputStream openFileOutput = openFileOutput("write.txt",
                    MODE_WORLD_WRITEABLE);
            openFileOutput.write("write".getBytes());
            openFileOutput.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void readClick(View v) {
        try {
            FileOutputStream openFileOutput = openFileOutput("read.txt",
                    MODE_WORLD_READABLE);
            openFileOutput.write("read".getBytes());
            openFileOutput.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void wrClick(View v) {
        try {
            FileOutputStream openFileOutput = openFileOutput("wr.txt",
                    MODE_WORLD_READABLE+MODE_WORLD_WRITEABLE);
            openFileOutput.write("wr".getBytes());
            openFileOutput.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

你可能感兴趣的:(创建不同权限的文件 openfileoutput)