Displaying Source Code(s)
|
|
demonstrate file
--------------------------------------------------------------------------------
Description : A File object is used to obtain or manipulate
information associated with a disk file such as permissions ,time,date
and directory path and to navigate subdirectory hierachies. File
class in present in io package
Code :
import java.io.File;
class file1
{
static void p(String s)
{
System.out.println(s);
}
public static void main(String args[])
{
File f1=new File("hi.java");
p("FILE NAME:"+f1.getName());
p("PATH NAME:"+f1.getPath());
p("ABSOLUTE PATH:"+f1.getAbsolutePath());
p(f1.exists()?"exists":"does not exist");
p(f1.canWrite()?"is writable":"is not writeable");
p(f1.canRead()?"is readable":"is not readable");
p("is"+(f1.isDirectory()?"":"not"+"a directory"));
p(f1.isFile()?"is normal file":"might be a named
pipe");
p(f1.isAbsolute()?"is absolute":"is not absloute");
p("file last modified"+f1.lastModified());
p("file size:"+f1.length()+"bytes");
}
} |
|
|