Java-Create New File

Create New File The createNewFile( ) method is creates a new empty file, returning true on success and false on failure. Failure indicates that the path specified in the File object already exists. Note this method is enclosed in a try block and followed by a catch block. This is necessary because the createNewFile( ) method … Read more…

Java-Create New Directory

Create New Directory The mkdir( ) method creates a directory, returning true on success and false on failure. Failure indicates that the path specified in the File object already exists, or that the directory cannot be created because the entire path does not exist yet. Program Program Source import java.io.File; public class Javaapp { public … Read more…

Java-Get Specific File Properties

Get Specific File Properties File defines many methods that obtain the standard properties of a File object. For example, canWrite( ) method Tests whether the application can modify the file, canRead( ) method Tests whether the application can read the file, isHidden( ) method Tests whether the file named by this abstract pathname is a … Read more…

Java-Get File Names

Get File Names The list( ) method is used to get the file names. This method returns an array of strings naming the files and directories in the directory denoted by this abstract pathname. Program Program Source import java.io.File; public class Javaapp { public static void main(String[] args) { File f1 = new File(“F:\\java8″); System.out.println(“Folder Name … Read more…

Java-File

File Java.io package provides a class known as the File class that provide support for creating files. It deals directly with files and the file system. That is, the File class does not specify how information is retrieved from or stored in files; it describes the properties of a file itself. A File Object is … Read more…