In this section we will discuss about the File class in Java.
A Computer File is used to store the data. These data can be String, characters, numbers etc and may arranged in string, rows, columns, lines etc. In Java we can also create a File to store the data. To create file in Java a class named File is provided in java.io package. Using constructors and methods of this class a Java programmer can create a new file. File.createNewFile() method creates the new file. java.io.File creates the new file with the abstract directory path names. An O/S and user interfaces point of view file and directories names are named as system dependent pathname strings. java.io.File introduced an abstract, system independent file and directory pathnames. This pathname contains the following two components :
Constructor Detail
| File(File parent, String child) | This constructor is used to create a new File object with the parent path name and
child pathname. Syntax : public File(File parent, String child) |
| File(String pathname) | This constructor is used to create a new File object with specified file pathname. Syntax : public File(String pathname) |
| File(String parent, String child) | This constructor is used to create a new File object with the specified parent
pathname and child pathname. Syntax : public File(String parent, String child) |
| File(URI uri) | This constructor is used to create a new File object by converting a
specified URI into pathname. Syntax : public File(URI uri) |
Method Detail
java.io.File has various methods some commonly used methods are as follows :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java IO File
Post your Comment