标签:print path span output new nbsp strong oid mamicode
当需要把内存中的数据存储到持久化设备上这个动作称为输出(写)Output操作。
当把持久设备上的数据读取到内存中的这个动作称为输入(读)Input操作。
因此我们把这种输入和输出动作称为IO操作。

1 import java.io.File;
2 import java.io.IOException;
3
4 public class Test1 {
5 public static void main(String[] args) {
6 File f=new File("d:"+java+"test.txt");File.separator
7 try {
8 f.createNewFile();
9 } catch (IOException e) {
10 e.printStackTrace();
11 }
12 }
13 }
删除一个指定文件
1 import java.io.File;
2
3 public class Test2 {
4 public static void main(String[] args) {
5 File f=new File("d:"+java+"test.txt");
6 if(f.exists()){//判断文件存不存在,如不存在就不用删除了
7 f.delete();
8 }
9 }
10 }
listFiles()与list()两种列出的方法
public static void getPath(){
File file = new File("D:\\java");
/*String [] files= file.list();
for(String s:files){
System.out.println(s);
}*/
File [] arr = file.listFiles();
for (File f:arr){
System.out.println(f.length());
}
}
标签:print path span output new nbsp strong oid mamicode
原文地址:https://www.cnblogs.com/0826sw/p/12317083.html