Create file object
File(File parent, String child)
- Creates a new File instance from a parent abstract pathname and a child pathname string.
File(String pathname)
- Creates a new File instance by converting the given pathname string into an abstract pathname.
File(String parent, String child)
- Creates a new File instance from a parent pathname string and a child pathname string.
File(URI uri)
- Creates a new File instance by converting the given file: URI into an abstract pathname.
import java.io.File;
public class Main {
public static void main(String[] args) {
File file = new File("c:/aFolder/aFile.txt");
System.out.println(file);
}
}
The output:
c:\aFolder\aFile.txt
import java.io.File;
public class Main {
public static void main(String[] args) {
File parent = new File("c:/aFolder");
File aFile = new File(parent, "aFile.txt");
System.out.println(aFile);//c:\aFolder\aFile.txt
}
}
Home
Java Book
File Stream
Java Book
File Stream
File:
- File
- Constants from File class
- Create file object
- Is it executable, readable or writable
- Compare two file path
- Create a file
- Delete a file
- Is it a file or a directory
- Whether the file or directory denoted by this abstract pathname exists
- Whether this abstract pathname is absolute
- Is this file hidden
- Get the file last modified time
- Get the file size
- Get file path and name
- Get free space, total space, usable space
- Get parent file
- Return file in a directory
- The file system roots
- Create new directories
- Rename file
- Change to executable, readable, writable
- Change last-modified time
- Get string representation of a file location
- Convert file location to URI and URL