file isAbsolute Example
file class isAbsolute example. This example shows you how to use isAbsolute method.
File class isAbsolute example. method generates boolean results after testing the abstract pathnames of file or directory to be absolute. this test is system dependent on Unix it just checks this '/' sign and on Microsoft it wants '\\' or '\\\'signs.method is being called by a boolean variable.
Here is the code:-
/**
* @Program uses isAbsolute method to check the absoluteness
* of the abstract pathname passed.
* IsAbsolute.java
* Author:-RoseIndia Team
* Date:-30-june-2008
*/
import java.io.File;
public class IsAbsolute {
public static void main(String args[]) {
File guilty = new File("/tmp/gconfd-mahendra"), guilty1 = new File(
"baadshah.txt"), cramp = new File("/"), cramp1 = new File("//");
boolean b1 = guilty.isAbsolute(), b2 = guilty1.isAbsolute(), b3 = cramp
.isAbsolute();
System.out.println("Absoluteness results");
System.out.println("File guilty: " + b1 + "\n" + "File guilty1: " + b2
+ "\n" + "File cramp: " + b3);
}
} |
Output of the program:-
Absoluteness results
File guilty: true
File guilty1: false
File cramp: true |
|