Java File Properties
// File handling in java
// File Properties
import java.io.*;
class FileProperties
{
public static void main(String as[]) throws IOException
{
File fin = new File("ipt.txt");
if (!fin.exists())
System.out.println("\nError: The file does not exist.");
else
{
System.out.println("The file exists.");
System.out.println("File Properties:");
System.out.println("Name: " + fin.getName());
System.out.println("Absolute Path: " + fin.getAbsolutePath());
System.out.println("Is Directory: " + fin.isDirectory());
System.out.println("Is File: " + fin.isFile());
System.out.println("Can Read: " + fin.canRead());
System.out.println("Can Write: " + fin.canWrite());
System.out.println("Can Execute: " + fin.canExecute());
System.out.println("Hidden: " + fin.isHidden());
System.out.println("Size (bytes): " + fin.length());
}
}
}
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu