当前位置:网站首页>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();
}
}
}
边栏推荐
- Installation and use of serial port packet capturing / cutting tool
- Take you ten days to easily complete the go micro service series (I)
- Network security - DNS spoofing and phishing websites
- View of MySQL
- How is the mask effect achieved in the LPL ban/pick selection stage?
- Network security - firewall
- LabVIEW安装第三方VISA软件后NI VISA失效
- [error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
- Qtablewidget lazy load remaining memory, no card!
- Huakaiyun (Zhiyin) | virtual host: what is a virtual host
猜你喜欢
High resolution network (Part 1): Principle Analysis
View of MySQL
Query product cases - page rendering data
[shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)
【Camera专题】手把手撸一份驱动 到 点亮Camera
[data mining] task 5: k-means/dbscan clustering: double square
[camera topic] how to save OTP data in user-defined nodes
【Camera专题】OTP数据如何保存在自定义节点中
自定义组件、使用npm包、全局数据共享、分包
PS去除水印详解
随机推荐
【Camera专题】Camera dtsi 完全解析
PS去除水印详解
[camera special topic] Hal layer - brief analysis of addchannel and startchannel
Network security - dynamic routing protocol rip
Summary of interval knowledge
Network security - scan
Everything文件搜索工具
Network security - scanning and password explosion 2
网络安全-浅谈安全威胁
[data mining] task 1: distance calculation
2022 spring "golden three silver four" job hopping prerequisites: Software Test interview questions (with answers)
Network security - the simplest virus
转载收录6.5大侠写的部分Qt开发经验
网络安全-NAT网络地址转换
网络安全-openvas
[shutter] animation animation (basic process of shutter animation | create animation controller | create animation | set value listener | set state listener | use animation values in layout | animatio
STM32 - switch of relay control lamp
The technology boss is ready, and the topic of position C is up to you
SSL flood attack of DDoS attack
2022 financial product revenue ranking