Advertisement
nRikee

Classe ls

May 7th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. /**
  4.  * Write a description of class consola here.
  5.  *
  6.  * @author nRikee93 (Twitter)
  7.  * @version (a version number or a date)
  8.  */
  9. public class ls
  10. {
  11.     public static void main(String[] args){
  12.         File f = new File(args[0]);
  13.        
  14.         if( f.exists() ) {
  15.             if ( !f.isDirectory() )  System.out.println("Nom fitxer: " +f.getName()+ "\nTamany: " + f.length() );
  16.             else {
  17.                 File[] fitxers = f.listFiles();
  18.                 System.out.println("Nom\t\tTamany");
  19.                 for (int a=0; a<fitxers.length; a++)
  20.                     System.out.println( fitxers[a].getName()+ "\t" + fitxers[a].length()  );
  21.             }
  22.         }
  23.     }  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement