Java Blog


class  FileDemo
    static void p(String s){
           System.out.println(s); }

    public static void main(String[] args) 
        File f1 = new File(\"Copyright.txt\"); 
        //If drive name is not specified than it take 
        //default drive where the prog is stored 
        //eg: here e: (e drive) as prog is stored on e:
        //You should mention drive explicitly

        p(\"File Name : \" + f1.getName());
        p(\"Path : \"+f1.getPath());
        p(\"Absoulte Path : \"+f1.getAbsolutePath());
        p(\"Parent : \"+f1.getParent());
        p(f1.exists() ? \"Exists\" : \"Does not Exists\");
        p(f1.canWrite() ? \"is Writable\" : \"is not Writable\");
        p(f1.canRead() ? \"is Readable\" : \"is not Readable\");
        p(f1.isDirectory() ? \"\" : \"is not \" + \"a directory\");
        p(f1.isFile() ? \"is a Normal File\" : \"might me be a named pipe\");
        p(\"File last Modified : \"+ f1.lastModified());
        p(\"File size : \"+f1.length() + \" Bytes\");

    Related Post:
  1. Program to show the use of Comparison operator (==) for comparing Strings

  2. An applet program to display barchart of given data

  3. An applet program to display Vertical Color Bar

  4. Program to show an example of creating Character Arrays from String objects

  5. Program using session tracking capability of Servlets, which displays information of current user session by HttpServletRequest object

  6. Program to show the use of operator (>>) Shift Right, propagating the sign bit from the left

  7. Program to show an example of Multiple Levels of Inheritance

  8. Program in CORBA which takes a long sentence from client (at least 7 words), passes to the server, server separates out each word and sends back

  9. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  10. Program which will read a string and rewrite it in the alphabetical order

  11. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

  12. Program to print some text on the same line using multiple print statements

  13. Program of binary search tree

  14. Program to delete mth element from an input string

  15. Corba program of Count Client Applet, IDL,Server, Client

  16. Socket program of HTTP Server

  17. Program to declare and initialize Boolean variables and print them on the Standard Output Device

  18. Program to show the use of Break Statement

  19. Program to represent a bank account

  20. Program to show some properties of StringBuffer object

Didn't find what you were looking for? Find more on Program to display attributes of a specified file