当前位置:网站首页>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)
}
边栏推荐
- golang操作redis:写入、读取hash类型数据
- Getting started with pytest
- Arctic code vault contributor
- Understand software testing
- 机械观和系统观的科学思维方式各有什么特点和作用
- Interfaces and related concepts
- 保险公司怎么查高血压?
- Notes on the core knowledge of Domain Driven Design DDD
- 每日刷題記錄 (十一)
- Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
猜你喜欢

dataworks自定義函數開發環境搭建

Ruoyi interface permission verification

每日刷題記錄 (十一)

JMeter JSON extractor extracts two parameters at the same time

Reading notes of "learn to ask questions"

My 2020 summary "don't love the past, indulge in moving forward"

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

(翻译)异步编程:Async/Await在ASP.NET中的介绍

The 10000 hour rule won't make you a master programmer, but at least it's a good starting point

Notes on the core knowledge of Domain Driven Design DDD
随机推荐
(翻译)异步编程:Async/Await在ASP.NET中的介绍
Shim and Polyfill in [concept collection]
Realize PDF to picture conversion with C #
多个全局异常处理类,怎么规定执行顺序
10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
Climb movie paradise 2021 hot
Thoughts in Starbucks
The education of a value investor
RestHighLevelClient获取某个索引的mapping
EasyExcel
JS date comparison
golang操作redis:写入、读取hash类型数据
爬虫代码基础教学
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
10000小時定律不會讓你成為編程大師,但至少是個好的起點
10000小时定律不会让你成为编程大师,但至少是个好的起点
如何迁移或复制VMware虚拟机系统
How to specify the execution order for multiple global exception handling classes
Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库