Javase (20) recursion, Io stream, self-learning character stream

Source: Internet
Author: User

1: Recursion (understanding)

(1) The phenomenon of invoking the method itself in the method definition

Old monks tell stories to little monks, we learn to program

(2) the notice of recursion;

A: To have an exit, or a death recursion

B: Not too many times, or memory overflow

C: Construction method cannot be used recursively

(3) Cases of recursion

A: recursion to find factorial

B: the rabbit Problem

C: Recursive output file absolute path for all specified suffix names under the specified directory

D: Recursively delete directories with content (use caution)

2:io Flow (Master)

(1); O for the operation of data transfer between devices

(2) Classification

A: Flow Direction

Input stream Read Data

Output stream writes out data

B: Data type

BYTE stream

BYTE input stream

BYTE output stream

Character Stream

Character input stream

Character output stream

Attention:

A: If we do not specify according to what points, by default according to the data type of

B: Unless the file is opened in a Windows-brought Notepad we can read it before using a character stream, otherwise we recommend using a byte stream

(3) Fi1eoutputotream Write Data

A: Operation procedure

A: Create a byte output stream object

B: Weekly Write () method

B: Code representation

FileOutputStream fos = new FileOutputStream ("Fos.txt");

Fos.write ("he11o". GetBytes ());

Fos.close ();

C: Issues to be aware of

A: How many things do you do to create a byte output stream object?

B: Why C1ose ()?

C: How to implement the data line wrapping?

D: How to implement the data append write?

(4) Fi1einputstream reading data

A: Operation procedure

A: Create a byte input stream object

B: Call the Read () method

C: Releasing Resources

B: Code representation

Fi1einputstream fis= New Fi1einputstream ("Fos. TXT ");

Mode 1

int by = 0;

while ((By=fis.read ())!=-1) {

System.out.print ((char) by);

}

Mode 2

byte[] bys = new byte[1024];

int len = 0;

while ((Len=fis.read (bys))!=-1) {

Systen.out.print (New String (Bys,0,len));

}

(5) Case: 2 Kinds of implementations

A: Copy A text file

B: Copy Picture

C: Copy Video

(6) Byte buffer stream

A:bufferedoutputstream

B:bufferedinputstream

(7) Case: 4 Kinds of implementations

A: Copy A text file

B: Copy Picture

C: Copy Video

3: Self-taught character stream

IO Stream classification

BYTE stream

InputStream

FileInputStream

Bufferedinputstream

OutputStream

FileOutputStream

Bufferedoutputstream

Character Stream

Reader

FileReader

BufferedReader

Writer

FileWriter

BufferedWriter

Javase (20) recursion, Io stream, self-learning character stream

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.