The following program returns various information about a file that can't exist on any platform!
import java.io.*;
public class FileInfo {
public static void main(String[] args) {
File f = new File("-What/a\bad file name?!" + '\u0000');
System.out.println("getName: " + f.getName());
System.out.println("getPath: " + f.getPath());
System.out.println("getAbsolutePath: " + f.getAbsolutePath());
System.out.println("getParent: " + f.getParent());
if (f.isFile()) {
System.out.println(f.getName() + " is a file.");
}
else if (f.isDirectory()) {
System.out.println(f.getName() + " is a directory.");
}
else {
System.out.println("What is this?");
}
if (f.isAbsolute()) {
System.out.println(f.getName() + " is an absolute path.");
}
else {
System.out.println(f.getName() + " is not an absolute path.");
}
}
}