Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.io.File;
- public class Main {
- public static void main(String[] args) throws IOException {
- File file = new File(".");
- File[]files=file.listFiles();
- func(file);
- }
- static void func(File file)
- {
- File[]files=file.listFiles();
- for(File f : files)
- {
- getPermissions(f);
- if(f.isDirectory())
- func(f);
- }
- }
- static void getPermissions(File f)
- {
- String pom="";
- if(f.canRead())
- {
- pom+="R";
- }else pom+=" ";
- if(f.canWrite())
- {
- pom+="W";
- }else pom+=" ";
- if(f.canExecute())
- {
- pom+="X";
- }else pom+=" ";
- System.out.println(f.getName()+" "+ pom);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment