Browse Source

List items and permissions

main
Jesus 2 years ago
parent
commit
7a060ae8bb
2 changed files with 21 additions and 1 deletions
  1. BIN
      bin/com/jesuspinar/gestorFichero/Util.class
  2. +21
    -1
      src/com/jesuspinar/gestorFichero/Util.java

BIN
bin/com/jesuspinar/gestorFichero/Util.class View File


+ 21
- 1
src/com/jesuspinar/gestorFichero/Util.java View File

@ -8,7 +8,7 @@ public class Util {
File f = new File(path); File f = new File(path);
if(f.isDirectory()) { if(f.isDirectory()) {
System.out.println(f.getAbsolutePath()); System.out.println(f.getAbsolutePath());
listItems(f);
listItemsArgs(f);
} }
} }
@ -18,4 +18,24 @@ public class Util {
System.out.println(i); System.out.println(i);
} }
} }
public static void listItemsArgs(File f){
File[] items = f.listFiles();
StringBuilder sb = new StringBuilder();
for(File i : items) {
if(i.isDirectory()) {
sb.append("d");
}
if(i.canRead()) {
sb.append("-r");
}
if(i.canWrite()) {
sb.append("-w");
}
if(i.canExecute()) {
sb.append("-x");
}
System.out.printf("%s %s\n", sb.toString(), i.getName());
sb.setLength(0);
}
}
} }

Loading…
Cancel
Save