Java Tutorial

 
 
 
 
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. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  2. Program to reverse the number eg given no : - 12345, output want :- 54321

  3. File Handling- JAVA

  4. 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

  5. Program to extract a portion of a character string and print the extracted string

  6. Program to show the use of Logical or Boolean Negation i.e. NOT (!)

  7. Program to show the use of Conditional AND Operator (&&) in If Statements

  8. Program to change characters in a StringBuffer objects and to reverse its contents

  9. Program to represent a bank account

  10. Socket program of multi client chat server

  11. Program to show an example of searching Strings for characters

  12. Corba program to encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time.

  13. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

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

  15. Program that will count the number of lines in each file that is specified on the command line

  16. Program to show the use of operator (<<) Shift Left filling with zero from the right

  17. An applet program to display alternate filled and empty circle that to in row and column format

  18. Program to show an example of using a recursive method in a class

  19. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  20. 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

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