Java BASICS (19) IO streams (2), java basics io streams

Source: Internet
Author: User

Java BASICS (19) IO streams (2), java basics io streams

Here are some of the knowledge points and code I summarized in my previous class. Most of the notes I think are very good and classic, sincerely hope that these will help those who want to learn!

It is inconvenient to upload code by module. There are also many things, and they are also clear! If you need it, you can leave your email in the comments. I will certainly send it to you for free! Thank you for making progress on this platform !! Remember that programmers are selfless !!!

Also very welcome to my blog to watch blog address:


/* 1: recursion (understanding) (1) The phenomenon of calling the method itself in the method definition example: the old monk tells the story to the little monk, we learn programming (2) recursive considerations;: there must be an exit, otherwise it is dead recursion B: The number of times cannot be too large, otherwise memory overflow C: constructor cannot recursively use (3) recursive case: A: recursion to find the factorial B: rabbit Problem C: recursively output the absolute path of all files with the specified Suffix in the specified directory D: recursively delete directories with content (use with caution) 2: IO stream (master) (1) IO is used for data transmission between devices (2) classification: A: flow to the input stream to read data from the output stream to write data B: data Type byte stream byte input stream byte output stream byte stream character input stream character output stream Note: a: if we do not explicitly specify the score, the default score is based on the data type. B: The byte stream is recommended unless the file is opened in the notepad provided by windows. (3) FileOutputStream write data A: operation step a: Create A byte output stream object B: Call the write () method c: release resource B: Code embodiment: fileOutputStream fos = new FileOutputStream ("fos.txt"); fos. write ("hello ". getBytes (); fos. close (); C: What should I pay attention? A: How many operations have you done to create a byte output stream object? B: Why close ()? C: How to implement data line feed? D: How to append and write data? (4) FileInputStream reading data A: operation step a: Create A byte input stream object B: Call the read () method c: release resource B: Code embodiment: fileInputStream FCM = new FileInputStream ("fos.txt"); // method 1 int by = 0; while (by = fiis. read ())! =-1) {System. out. print (char) by);} // method 2 byte [] bys = new byte [1024]; int len = 0; while (len = FCM. read (bys ))! =-1) {System. out. print (new String (bys, 0, len);} FCM. close (); (5) Case: two implementations A: copying A text file B: copying an image C: copying A video (6) byte buffer Stream A: BufferedOutputStream B: BufferedInputStream (7) case: Four implementations A: copying text files B: copying images C: copying videos 3: self-taught streams IO streams classification byte streams: InputStream FileInputStream BufferedInputStream OutputStream FileOutputStream BufferedOutputStream streams: reader FileReader BufferedReader Writer FileWriter BufferedWriter *\


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: 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.