Common IO flow and file class theory summary of Io in Java

Source: Internet
Author: User

The summary is very rough, the later time is rich to revise a bit well.

The 1:java language defines many classes that are specifically responsible for input or output in various ways, and these classes are placed in the java.io package. where all input stream classes are abstract class InputStream (byte input stream) or subclass of abstract class reader (character input stream), all output streams are subclasses of abstract class OutputStream (byte output stream) or writer (character output stream).

The first thing to understand is: what is the flow??? (For permanent data retention)

The input stream and output stream are divided according to the different data flow.

According to the different types of processing data are divided into character stream and byte stream;

"Then you need to understand that the input mode and the output mode are who flows to who:

Inputstream (byte input stream) and reader (character input stream) The popular understanding is read.

OutputStream (byte output stream) and writer (character output stream) The popular understanding is written (writer).

Finally, the following figure out the type of various types of how to use, who contains who, to clarify the idea.

The 2:inputstream class is the abstract class of the byte input stream, which is the parent class of all byte input streams, and the InputStream class has a hierarchy as shown;

The characters in 3:java are Unicode encoded, double-byte, and thetext in various languages in Java is encoded in Unicode , andUnicode encoding is based on - bit of Char , so reading file data is more efficient and convenient through character streams. And some binary data read and write, than slices, sound, etc. must be done by byte stream. InputStream is used to process bytes, which is inconvenient when dealing with word literals. Java provides a specialized set of reader types for the input of character literals. The reader class is an abstract class of character input streams, and the implementation of all character input streams is its subclass.

4: Output stream The OutputStream class is an abstract class of byte input streams that represents the superclass of all classes that output a stream of bytes.

The 5:writer class is an abstract class of character output streams, and the implementation of all character output classes is its subclass.

The 6:file class is the only object in the IO package that represents the disk file itself. Create, delete, and rename files through file. The main function of the file class object is to get some information about the text itself. such as the directory where the text resides, the length of the file, read and write permissions, and so on. (Some need memory, such as Isfile (), isdirectory (), exits (); View API when used)

Details are as follows: File class (Overview and construction method of the file class) the A:file class's overview file should be called a path file path or folder path path divided into absolute path and relative path absolute path is a fixed path, from the beginning of the drive letter relative path relative to a location, in Eclip Se refers to the current project under DOS View API refers to the abstract representation of the current path file and directory Pathname B: Constructor method file (String pathname): Gets the file object file based on a path (string parent, String ch ILD): Get the File Object file (file parent, String child) according to a directory and a sub-file/directory: Get the File Object  file class (the File class creation function) According to a parent file object and a child file/directory A: Create feature public Boolean createnewfile (): Create a file if such a file exists, the public boolean mkdir () is not created: Create folder if such a folder exists, the public boo is not created Lean mkdirs (): Create a folder, if the parent folder does not exist, will help you create it (using the CreateNewFile () file created without a. txt or other suffix is also a file, not a folder; When you create a folder with MkDir (), If the name is such as Aaa.txt is also a folder is not a file; Note: If you create a file or a folder where you forgot to write the drive path, the default is under Project path.  file Class (Rename and delete function of file class) A: Rename and delete function public boolean renameto (file dest): Rename file to specified file path public boolean delete (): delete    File or folder B: Renaming considerations if the path name is the same, it is renamed.  If the path name is different, it is renamed and clipped.    C: Delete Note: Delete in Java does not go to the Recycle Bin. To delete a folder, note that the folder cannot contain files or Folders  file class (the function of the file Class) A: Judge function public boolean isdirectory (): Determines whether the directory public boolean ISFI Le (): Determine if the file is PuBlic Boolean exists (): Determines whether public boolean canRead (): Determines whether public boolean canWrite () is readable: Determines whether the public boolean Ishi is writable Dden (): Determine if hidden

File class (Fetch function of file Class) A: Gets the function public string GetAbsolutePath (): Gets the absolute path public string GetPath (): Gets the path public string Getna Me (): Gets the name public long length (): Gets the length. Bytes Public Long lastmodified (): Gets the last modified time, millisecond value public string[] List (): Gets the name array for all files or folders under the specified directory public file[] Listfi Les (): Gets the file array of all files or folders under the specified directory file class (overview and use of the filename filter) A: Overview of File name filters public string[] List (filenamefilter filter) public File[] Listfiles (filefilter filter)

Common IO flow and file class theory summary of Io in Java

Related Article

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.