File: canRead() : File « java.io « Java by API






File: canRead()

  
/*
 * Output:
 * 

File Name:MainClass.java
Path:MainClass.java
Abs Path:C:\Java_Dev\workspace\cal\MainClass.java
Parent:null
does not exist
is not writeable
is not readable
is a directoryfalse
might be a named pipe
is not absolute
File last modified:0
File size:0 Bytes

 * 
 *  
 */

import java.io.File;

public class MainClass {
    public static void main(String args[]) {
  File f1 = new File("MainClass.java");
  System.out.println("File Name:" + f1.getName());
  System.out.println("Path:" + f1.getPath());
  System.out.println("Abs Path:" + f1.getAbsolutePath());
  System.out.println("Parent:" + f1.getParent());
  System.out.println(f1.exists() ? "exists" : "does not exist");
  System.out.println(f1.canWrite() ? "is writeable" : "is not writeable");
  System.out.println(f1.canRead() ? "is readable" : "is not readable");
  System.out.println("is a directory" + f1.isDirectory() );
  System.out.println(f1.isFile() ? "is normal file" : "might be a named pipe");
  System.out.println(f1.isAbsolute() ? "is absolute" : "is not absolute");
  System.out.println("File last modified:" + f1.lastModified());
  System.out.println("File size:" + f1.length() + " Bytes");
    }
}

           
         
    
  








Related examples in the same category

1.File.pathSeparatorChar
2.File.separator
3.File: separatorChar
4.new File(String name)
5.new File(URI uri)
6.new File(String parent, String child)
7.File: canWrite()
8.File: createNewFile()
9.File: createTempFile(String prefix, String suffix)
10.File: delete()
11.File: deleteOnExit()
12.File: exists()
13.File: getAbsoluteFile()
14.File: getAbsolutePath()
15.File: getCanonicalPath()
16.File: getFreeSpace()
17.File: getName()
18.File: getParent()
19.File: getParentFile()
20.File: getPath()
21.File: getTotalSpace()
22.File: getUsableSpace()
23.File: isAbsolute()
24.File: isDirectory()
25.File: isFile()
26.File: listFiles()
27.File: isHidden()
28.File: lastModified()
29.File: length()
30.File: list()
31.File: listFiles(FilenameFilter filter)
32.File: listRoots()
33.File: mkdir()
34.File: mkdirs() (Creates a directory including any parent directories)
35.File: renameTo(File newFile)
36.File: setLastModified(long time)
37.File: setReadOnly()
38.File: setWritable(boolean writable)
39.File: toURI()
40.File: toURL()