Advertisement
piffy

Java Filesystem

Jan 2nd, 2018
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.IOException;
  3. import java.util.*;
  4.  
  5. public class FileProva {
  6.  
  7.         public static void lsDir(String path) {
  8.             File dir;
  9.             String[] list = null;
  10.             dir = new File(path);
  11.             list = dir.list();
  12.             Arrays.sort(list);
  13.             for (String s:list)
  14.                 System.out.println(s);
  15.         }
  16.  
  17.  
  18.     public static void main(String[] args) throws IOException {
  19.  
  20.         File theDir = new File("/home/piffy2/esperimenti");
  21.         if (!theDir.exists()) theDir.mkdir();
  22.         File f= new File("/home/piffy2/esperimenti/pippo.txt");
  23.         f.setExecutable(true);
  24.         f.setReadOnly();
  25.         System.out.println(f.length());
  26.         //f.delete();
  27.         lsDir("/home/piffy2");
  28.         System.out.println("Separatore percorso: "+File.pathSeparator+"\n Separatore di File\n"+File.separator);
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement