当前位置:网站首页>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)
}
边栏推荐
- DBNet:具有可微分二值化的实时场景文本检测
- Troubleshooting of high CPU load but low CPU usage
- Operation principle of lua on C: Foundation
- Liang Ning: 30 lectures on brain map notes for growth thinking
- Interface learning
- php安装composer
- Understand software testing
- How to plan well?
- MySQL installation
- Integration test practice (1) theoretical basis
猜你喜欢
HMS core helps baby bus show high-quality children's digital content to global developers
Summary of remote connection of MySQL
Integration test practice (1) theoretical basis
2022年华东师范大学计科考研复试机试题-详细题解
dataworks自定义函数开发环境搭建
Pytest -- write and manage test cases
Golang operation redis: write and read hash type data
Winter vacation work of software engineering practice
In depth analysis of reentrantlock fair lock and unfair lock source code implementation
【无标题】
随机推荐
Realize PDF to picture conversion with C #
Software testing learning - the next day
Modify MySQL password
Create your own deep learning environment with CONDA
2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)
机械观和系统观的科学思维方式各有什么特点和作用
[attribute comparison] defer and async
【类和对象】深入浅出类和对象
Jenkins
Practical plug-ins in idea
如何迁移或复制VMware虚拟机系统
Software testing assignment - day 3
Thoughts in Starbucks
Sorting out the core ideas of the pyramid principle
Error c2017: illegal escape sequence
[C /vb.net] convert PDF to svg/image, svg/image to PDF
CentOS switches and installs mysql5.7 and mysql8.0
DBNet:具有可微分二值化的实时场景文本检测
What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
Daily question brushing record (11)