9/28 clock in!
one:flie path
1.absolute path
2.relative path
if ensure a reference path,how find it's absolute path?
describe: ./ / /
what is ../?
3.work catalogue![](https://i-blog.csdnimg.cn/blog_migrate/b8070995168d34af62d089ddc6188cd6.png)
two:file create
1.first situation:
public class IO {
public static void main(String[] args) throws IOException {
File file=new File("C:/test.txt");
System.out.println(file.getParent());//父目录文件路径
System.out.println(file.getName());//纯文件name
System.out.println(file.getPath());//single path name
System.out.println(file.getAbsoluteFile());
System.out.println(file.getCanonicalFile());
}
}
2.second situation
we are using the IDEA,so the work catalogue is the directory of the open project.
public class IO {
public static void main(String[] args) throws IOException {
File file=new File("./test.txt");
System.out.println(file.getParent());//父目录文件路径
System.out.println(file.getName());//single file name
System.out.println(file.getPath());//single path name
System.out.println(file.getAbsoluteFile());
System.out.println(file.getCanonicalFile());
}
}
3. phe no me non
the "test.txt" was not found to exist,but if not find out,able to create it
public class IO {
public static void main(String[] args) throws IOException {
File file=new File("./test.txt");
System.out.println(file.exists());
System.out.println(file.isFile());
System.out.println(file.isDirectory());
file.createNewFile();
System.out.println(file.exists());
System.out.println(file.isFile());
System.out.println(file.isDirectory());
}
}
Three:file delete
![](https://i-blog.csdnimg.cn/blog_migrate/9c7dcad18f60749468490839855463d5.png)
Four:create file's catalogue
1.create single-deck catalogue
2.create multideck catalogue
public class IO {
public static void main(String[] args) throws IOException {
//File file=new File("./test.txt");
//file.mkdir();
File file=new File("./test.txt/aaa/bbb");
file.mkdirs();
}
}
3. list file
public class IO {
public static void main(String[] args) throws IOException {
File file=new File("./test");
String[] result = file.list();
System.out.println(Arrays.toString(result));
}
}