当前位置:网站首页>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
- [classes and objects] explain classes and objects in simple terms
- 熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
- Resttemplate configuration use
- C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
- New knowledge! The virtual machine network card causes your DNS resolution to slow down
- Create your own deep learning environment with CONDA
- Personally design a highly concurrent seckill system
- Setting up the development environment of dataworks custom function
- UTC时间、GMT时间、CST时间
猜你喜欢

深度学习参数初始化(一)Xavier初始化 含代码

JUC forkjoinpool branch merge framework - work theft

JMeter JSON extractor extracts two parameters at the same time

Summary of the design and implementation of the weapon system similar to the paladin of vitality

The dynamic analysis and calculation of expressions are really delicious for flee

Inno setup production and installation package

卡特兰数(Catalan)的应用场景

Summary of remote connection of MySQL

Ruoyi interface permission verification
![[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
随机推荐
php artisan
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
golang操作redis:写入、读取hash类型数据
php安装swoole扩展
MySQL installation
多个全局异常处理类,怎么规定执行顺序
Climb movie paradise 2021 hot
centos php7.3安装redis扩展
萬卷書 - 價值投資者指南 [The Education of a Value Investor]
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
Know flex box
Win 10 find the port and close the port
Daily question brushing record (11)
每日刷題記錄 (十一)
mongodb
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
PHP install the spool extension
How to specify the execution order for multiple global exception handling classes
Thoughts in Starbucks