File §2
Previously speaking,File can be seen as one ducument, also can be seen as list of documents like directory.
Here,File also can be seen as one directory which does't exist, also can be seen as a whole path of directory which does't exist.
Example1:
File f = new File("C:/Users/caich5/Desktop/test");
if(!f.exist()){
f.mkdirs();
}
If succeed,Directory 'test' will show in the path of 'C:/Users/caich5/Desktop';
File f = new File("C:/Users/caich5/Desktop/test/test/test");
if(!f.exist()){
f.mkdirs();
}
If succeed,Directory 'test/test/test' will show in the path of 'C:/Users/caich5/Desktop';
Tips:difference between file.mkdirs() and file.mkdir();
file.mkdirs(): it means that you can create multi-layer path;
file.mkdir(): it means that you can only create the single-layer path;
Example2:
File f = new File("C:/Users/caich5/Desktop/test.txt");
if(!f.exist()){
f.createNewFile();
}