当前位置:网站首页>File class (add / delete)
File class (add / delete)
2022-07-03 01:52:00 【Xu Feng &】
1, establish ( increase )
There are methods :
1,[createNewFile()] create a file
2,[mkdir()] Create folder
3,[mkdirs()] Create a folder in the folder ,( Just creating File Write more when class )
4,[delete()] Delete file
These can be used in the following ways, just change file. The back one is OK
import java.io.File;
import java.io.IOException;
public class filedemo1 {
public static void main(String[] args) {
File file =new File("D:\\abc.txt");
boolean f1 =file.createNewFile();
}
}
2, Use ctrl+alt+t use try/catch Method wrap the middle
import java.io.File;
import java.io.IOException;
public class filedemo1 {
public static void main(String[] args) {
try {
File file =new File("D:\\abc.txt");
boolean f1 =file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Output
import java.io.File;
import java.io.IOException;
public class filedemo1 {
public static void main(String[] args) {
try {
File file =new File("D:\\abc.txt");
boolean f1 =file.createNewFile();
System.out.println(f1?" Create success ":" Create failure ");
} catch (IOException e) {
e.printStackTrace();
}
}
}
边栏推荐
- [camera topic] how to save OTP data in user-defined nodes
- 网络安全-openvas
- [error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
- Pytest learning notes (12) -allure feature · @allure Step () and allure attach
- [technology development-23]: application of DSP in future converged networks
- [understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
- ¢ growth path and experience sharing of getting an offer
- Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
- 【数据挖掘】任务3:决策树分类
- LabVIEW安装第三方VISA软件后NI VISA失效
猜你喜欢
![[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)](/img/3c/93ef853784d4e7cef63f30be0b0bf2.jpg)
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)

可视化yolov5格式数据集(labelme json文件)

Summary of interval knowledge

STM32 - Application of external interrupt induction lamp

Learn the five skills you need to master in cloud computing application development

In the face of difficult SQL requirements, HQL is not afraid

LabVIEW安装第三方VISA软件后NI VISA失效

How is the mask effect achieved in the LPL ban/pick selection stage?
![[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait](/img/c6/9aee30cb935b203c7c62b12c822085.jpg)
[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait

Sweet talk generator, regular greeting email machine... Open source programmers pay too much for this Valentine's day
随机推荐
Learn the five skills you need to master in cloud computing application development
Analysis, use and extension of open source API gateway apisex
GDB 在嵌入式中的相关概念
ByteDance data Lake integration practice based on Hudi
2022 spring "golden three silver four" job hopping prerequisites: Software Test interview questions (with answers)
7-25 read numbers (loop switch)
Network security NAT network address translation
Openresty cache
Network security - the simplest virus
网络安全-最简单的病毒
[camera special topic] Hal layer - brief analysis of addchannel and startchannel
网络安全-中间人攻击
[data mining] task 6: DBSCAN clustering
【数据挖掘】任务6:DBSCAN聚类
Bottleneck period must see: how can testers who have worked for 3-5 years avoid detours and break through smoothly
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
STM32 - vibration sensor control relay on
Learn BeanShell before you dare to say you know JMeter
Steps to obtain SSL certificate private key private key file
Network security - scan