Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to create the File class

Shulou Source: shulou.com Published: 2022-06-01 10:56:06 09月27日 Update

This article mainly explains "how to create File class". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to create File class.

Overview

File is the only path in the IO package that represents files and disk directories. Includes creating, deleting, renaming, getting file information, etc. However, File cannot access the contents of the file itself. If you need to access the contents of the file itself, you need to use the input / output stream.

Constructor File (String pathname)

Create a File object with pathname as the path, either an absolute path or a relative path, and if pathname is a relative path, the default current path is stored in the system property user.dir.

File (String parent,String child)

Create a File object with parent as the parent path and child as the child path.

File (File parent,String child)

Get objects from parent File objects and child files / directories

Path separator

Each level of directory in the path is separated by a path separator.

Create public boolean createNewFile (): create a file. If the file exists, do not create it, return false  public boolean mkdir (): create the file directory. If this file directory exists, it will not be created. If the upper directory of this file directory does not exist, it will not be created.  public boolean mkdirs (): creates a file directory. If the upper file directory does not exist Create file path File getAbsoluteFile (): get absolute path String getAbsolutePath (): get absolute path String getPath (): get file path String getName (): get file name File getParentFile (): get parent directory file String getParent (): get parent directory path file attribute boolean canExecute (): determine whether it is an executable file boolean canRead (): determine whether the file is readable boolean canWrite ( ): determine whether the file is writable boolean isHidden (): determine whether the file is hidden long lastModified (): determine the last modification time of the file. Thank you for reading. The above is the content of "how to create the File class". After the study of this article, I believe you have a deeper understanding of how to create the File class, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Files paths directories objects content learning upper levels superiors delimiters attributes between information functions names that is ideas situations articles time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Xiaomi Shulou Information Microsoft OPPO Reno