Java advanced video _ IO Input and Output 01 learning notes

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.