当前位置:网站首页>Advanced API (use of file class)
Advanced API (use of file class)
2022-07-03 07:01:00 【Bugxiu_ fu】
File The acquisition function of
Get file size :file.length()
Get the absolute path of the file :file.getAbsolutePath()
Get the path of the file :file.getPath()
Get the name of the file :file.getName()
Get the last modification time of the file (1970 year 1 month 1 Millisecond value of day ):file.lastModified()
long time = file.lastModified();
adopt util In bag Date Object to convert
Date date = new Date(time);
System.out.println(date.toLocaleString());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy year MM month dd Japan HH:mm:ss");
System.out.println(sdf.format(date));
File Class
1. Judgment method
* exists Judge whether it exists
* isFile Determine whether or not to file
* isHidden Determine whether it is a hidden file
* isDirectory Determine whether it is a folder
*
* 2. New features
* createNewFile Create a new file There are abnormal
* mkdir Create a single folder
* mkdirs Create multi-level folders
*
* 3. Delete function
* delete Delete file , Delete folder must be empty
*
* 4. Acquisition function
* length To obtain the length of the ( byte )
* getPath Path to file
* getAbsolutePath The absolute path to the file
* getName The name of the document
* lastModified Last modified time
* listRoots Disk root
* list All files and folder names in a directory
* listFiles All file objects in a directory
Construction method new File(String filePath);
Java Recursive method of
demand : complete 1+2+3....+100 Result 5050
@param args
public static int mySum(int num) {
if(num == 1) {
return 1;
}
return num+mySum(num-1);// 1+2+3 mySum(1)
}
边栏推荐
- Pits encountered in the use of El checkbox group
- vmware虚拟机C盘扩容
- Arctic code vault contributor
- Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
- Basic teaching of crawler code
- Stream stream
- 服务器如何设置多界面和装IIS呢?甜甜给你解答!
- 卡特兰数(Catalan)的应用场景
- Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
- Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
猜你喜欢
![[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*](/img/1f/f579110a408c5b5a094733be57ed90.jpg)
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
![[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle](/img/f8/0e3fbfd13bf06291a73200552ff17a.png)
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle

VMware virtual machine C disk expansion

golang操作redis:写入、读取kv数据

Software testing assignment - day 1

Application scenarios of Catalan number

Pits encountered in the use of El checkbox group

Create your own deep learning environment with CONDA

熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?

MySQL installation
随机推荐
2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)
Centos切换安装mysql5.7和mysql8.0
10000小时定律不会让你成为编程大师,但至少是个好的起点
Flask Foundation
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
Error c2017: illegal escape sequence
【code】if (list != null && list.size() > 0)优化,集合判空实现方式
[Code] occasionally take values, judge blanks, look up tables, verify, etc
Mise en place d'un environnement de développement de fonctions personnalisées
[classes and objects] explain classes and objects in simple terms
Selenium key knowledge explanation
Unit test notes
[Code] if (list! = null & list. Size() > 0) optimization, set empty judgment implementation method
UTC time, GMT time, CST time
In depth analysis of reentrantlock fair lock and unfair lock source code implementation
2022-06-23 VGMP-OSPF-域間安全策略-NAT策略(更新中)
POI excel percentage
Laravel frame step pit (I)
萬卷書 - 價值投資者指南 [The Education of a Value Investor]
Operation principle of lua on C: Foundation