Java Blog

 
 
 
import java.io.File;

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. An applet program to draw different shapes

  2. Program to show an example of using a Non-Static Nested Class

  3. Program to show the use of For Loop

  4. Program of an applet to illustrate BarChart

  5. Program to generate Fibonacci Series of a given number

  6. Program of reading and writing primitive data

  7. Develop a RMI based application for addition of two complex numbers

  8. Program to show the use of Nested If-Else Statements

  9. GUI application in java, which enter the details of a student and on the submit display the details of the student

  10. Program sets up a String variable containing a paragraph of text of your choice. Extract the words from the text and sort them into alphabetical order

  11. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object

  12. Dialog Boxes

  13. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

  14. Program of creating a file using text fields in windows

  15. Program to declare, initialize and print an array of integers

  16. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

  17. Program to show an example of creating a String object from a StringBuffer Object

  18. RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct

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

  20. Write a program for restaurant

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