The file class is located in the Java I/O package. Check out the documents. Both Chinese and English are abstract concepts. Today I watched instructor Zhang's video, all the problems left over in the past have been solved. First, the file defines the abstract representation of files and directory pathnames. If you do not do the experiment, this sentence is abstract, but you can watch the video, the files and directories in Java are not differentiated. If there are still files under the directory, it is not file 1.CodeEvidence: public class testfile {
Public static void main (string [] ARGs ){
File file = new file ("a.txt ");
If (file. exists ()){
File. Delete ();
} Else {
Try {
File. createnewfile ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
System. Out. println ("file name:" + file. getname ());
System. Out. println ("Path:" + file. getpath ());
}
}
}
both outputs are a.txt. Open the API. This is the core, because many of the methods in it operate on the "abstract path strength or file name". If you understand this, it is not difficult to understand other methods. If you cannot, let's take a look, at the same time, I also give myself some inspiration. Although the API is a technical document, it does not take time to read other technical documents without having to read them word by word, however, you must find out what type of returned values are, find keywords, and perform experiments. This is a good learning method.