File management
We have already used some methods for finding, creating, reading, and writing files using the JCL classes. We had to do it in order to support a demo code of input/output streams. In this section, we are going to talk about file management using the JCL in more detail.
The File
class from the java.io
package represents the underlying filesystem. An object of the File
class can be created with one of the following constructors:
File(String pathname)
: Creates a newFile
instance based on the provided pathnameFile(String parent, String child)
: Creates a newFile
instance based on the provided parent pathname and a child pathnameFile(File parent, String child)
: Creates a newFile
instance based on the provided parentFile
object and a child pathnameFile(URI uri)
: Creates a newFile
instance based on the providedURI
object that represents the pathname
We will now see some examples of the constructors’ usage while talking about creating...