In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The File class in the Java foundation is like this, and I believe many inexperienced people don't know what to do about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
In the rookie introduction to the basic Java learning road, File class is a knowledge point that must be contacted. In order to facilitate everyone to learn and apply the File class, the editor collates and summarizes the relevant knowledge points of the File class, including the overview and construction methods of the File class, the creation function of the file class, the judgment and acquisition function of the file class and the deletion function of the File class.
1. Overview and construction methods of File class
(1) introduction of File class
It is an abstract representation of file and directory pathnames. Files and directories can be encapsulated into objects through File. For File, it doesn't encapsulate a real file, just a pathname. It can exist or it may not exist. In the future, the content of this path will be transformed into concrete existence through specific operations.
(2) the construction method of File class
Method name: File (String pathname); description: create a new File instance by converting the given pathname string to an abstract pathname.
Method name: File (String parent, String child); description: create a new File instance from the parent path name string and the child path name string.
Method name: File (File parent, String child); description: create a new File instance from the parent abstract path name and child path name string.
Sample code:
2. File class creation function
(1) method classification
Method name: public boolean createNewFile (); description: when a file with that name does not exist, create a new empty file named by the abstract pathname.
Method name: public boolean mkdir (); description: create a directory named by this abstract pathname.
Method name: public boolean mkdirs (); description: create a directory named by this abstract pathname, including any required but non-existent parent directories.
Sample code:
3. The function of judging and obtaining File class
(1) judgment function
(2) get the function
4. Delete function of File class
(1) method classification
Method name: public boolean delete (); description: delete the file or directory represented by this abstract pathname.
(2) sample code:
After reading the above, have you mastered the method of the File class in the foundation of Java? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.