Friday, July 23, 2010

FILE STATUS

import java.io.*;
import java.util.*;
class files
{
public static void main(String args[]) throws IOException
{
Scanner in=new Scanner(System.in);
String name;
System.out.println("Enter  filename");
name=in.nextLine();
File f=new File(name);
System.out.println("Name of the file is:" +f.getName());
System.out.println("path of the file is:" +f.getPath());
System.out.println("parent of the file is:" +f.getParent());
System.out.println("File  exists :" +f.exists());
System.out.println("file is a  Directory:" +f.isDirectory());
System.out.println("file  is a ordinary file:" +f.isFile());
System.out.println("file has read permission:" +f.canRead());
System.out.println("file has write permission:" +f.canWrite());
System.out.println("size of the file is:" +f.length());
}
}

No comments:

Post a Comment

FOLLOWERS