Java Tutorial

 
 
 
 
import java.io.File;

class  DirList
{
    public static void main(String[] args) 
    {
         String dirname= \"e:/songs\";
         File f1 = new File(dirname);

    if (f1.isDirectory())
    {
              System.out.println(\"Directory of \" + dirname);
              String s[] = f1.list();

              for (int i=0;i<s.length ;i++ )
              {
                    File f = new File(dirname + \"/\"+ s[i]);
                    if (f.isFile()){
                         System.out.println(s[i] + \" is a File\");
                    }
                    else{
                        System.out.println(s[i] + \" is a directory\");
                    }
              }
     }
    else
    {
           System.out.println(dirname + \" is not  a directory\");
    }
    }
}

    Related Post:
  1. Program that accepts a shopping list of items from the command line and stores them in a vector. Also provide facility to perform operation

  2. Program to convert the given temperature in faherenhiet to celsius using the following conversion formula C= F- 32/1.8

  3. Program to show the comparing of Strings for equality

  4. Program to show an example of using constructors in a class to initialize its data members

  5. Program to show the use of Bitwise Operator (&) AND

  6. An applet program to draw different shapes

  7. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

  8. RMI application for getting the final total price of the shopping list with some of the following items and quantities chosen by the user

  9. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

  10. Even no or Prime no?????

  11. RMI program of count server and client

  12. Program to show the use of operator (&gt;&gt;) Shift Right, propagating the sign bit from the left

  13. Program to show an example of Concatination of Strings

  14. Program to print a string on Standard Output Device

  15. CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL

  16. Program to show the use of If-Else Statement

  17. Program of an applet to display alternate filled and empty circle

  18. Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong

  19. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  20. Program to show the use of Nested Loops

 
 
Didn't find what you were looking for? Find more on File handling program to display directory contents