当前位置:网站首页>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)
}
边栏推荐
- Crontab scheduled task
- [Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
- Interface learning
- What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
- php artisan
- Tool class static method calls @autowired injected service
- 2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
- 爬虫代码基础教学
- The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
- [set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
猜你喜欢

Operation principle of lua on C: Foundation

多个全局异常处理类,怎么规定执行顺序

MySQL installation

dataworks自定义函数开发环境搭建

2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)

Realize PDF to picture conversion with C #

Sorting out the core ideas of the pyramid principle

每日刷题记录 (十一)

Dbnet: real time scene text detection with differentiable binarization

2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
随机推荐
Software testing assignment - day 3
Upgrade CentOS php7.2.24 to php7.3
SQL implementation merges multiple rows of records into one row
Interface learning
Resthighlevelclient gets the mapping of an index
Search engine Bing Bing advanced search skills
MySQL transaction rollback, error points record
On the practice of performance optimization and stability guarantee
Notes on the core knowledge of Domain Driven Design DDD
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
php安装composer
保险公司怎么查高血压?
Resttemplate configuration use
【无标题】
【code】if (list != null && list.size() > 0)优化,集合判空实现方式
Basic teaching of crawler code
【类和对象】深入浅出类和对象
服务器如何设置多界面和装IIS呢?甜甜给你解答!
Redis command
Stream stream