I changed my profile
There is no package.
Here is the source code:
import java.io.*;
public class FileDemo {
public static void main (
String [] args) throws IOException {
// Create instances of File objects for directory
// and file entries
File dir = new File(File.separator + "Wrox" + File.separator
+ "docs");
File f1 = new File(dir, "test1.txt");
File f2 = new File(dir, "test2.doc");
File f3 = new File(dir, "test3.txt");
//FileDemo f = new FileDemo();
// Create directory and files
dir.mkdirs();
System.out.println("Directory \\Wrox\\docs created");
f1.createNewFile();
f2.createNewFile();
System.out.println("Files \"test1.txt\" and \"test2.doc\" created");
// Get file attributes
System.out.println("\nAttributes of \"test1.txt\" \n" +
"\n\"test1.txt\" exists: " + f1.exists() +
"\n\"test1.txt\" is a file: " + f1.isFile() +
"\n\"test1.txt\" is a directory: " + f1.isDirectory() +
"\nCan read from \"test1.txt\": " + f1.canRead() +
"\nCan write to \"test1.txt\": " + f1.canWrite() +
"\nThe absolute path of \"test1.txt\": " + f1.getAbsolutePath());
// Rename test2.doc to test3.txt
System.out.println("\nThe name of the file object f2 is "
+ f2.getName());
System.out.println("Renaming :\"test2.doc\" to \"test3.txt\"");
f2.renameTo(f3);
System.out.println("The name of the file object f3 is "+f3.getName());
// Delete all files and directory
System.out.println("\nDeleting files and directory ");
System.out.println("The file \"test1.txt\" is deleted: "
+ f1.delete());
System.out.println("The file \"test3.txt\" is deleted: "
+ f3.delete());
System.out.println("The directory docs is deleted: "
+ dir.delete());
}
//FileDemo f = new FileDemo();
}