Dab tsi yog input thiab output kwj?
Dab tsi yog input thiab output kwj?

Video: Dab tsi yog input thiab output kwj?

Video: Dab tsi yog input thiab output kwj?
Video: Data Science with Python! Analyzing File Types from Avro to Stata 2024, Kaum ib hlis
Anonim

Nyeem thiab sau cov ntaub ntawv. Raws li tau piav ua ntej, a ntws tuaj yeem txhais tau tias yog ib ntu ntawm cov ntaub ntawv. InputStream yog siv los nyeem cov ntaub ntawv los ntawm ib qhov chaw thiab cov OutputStream yog siv los sau cov ntaub ntawv mus rau qhov chaw. Ntawm no yog ib tug hierarchy ntawm cov chav kawm los nrog Input thiab Output kwj.

Ib yam li ntawd, dab tsi yog qhov input kwj?

Kev nkag kwj : Yog tias koj nyeem cov ntaub ntawv los ntawm cov ntaub ntawv lossis lwm qhov chaw, ntws siv yog input ntws . Hauv cov ntsiab lus yooj yim input ntws ua raws li channel los nyeem cov ntaub ntawv. Tso zis kwj : Yog tias koj xav nyeem thiab ua cov ntaub ntawv los ntawm qhov chaw (cov ntaub ntawv thiab lwm yam) koj yuav tsum xub khaws cov ntaub ntawv, qhov txhais tau tias khaws cov ntaub ntawv yog tso zis ntws.

Tom qab, lo lus nug yog, dab tsi yog byte kwj hauv Java? Java Byte ntws yog siv los ua input thiab output ntawm 8-ntsis bytes , hos Java Cim ntws yog siv los ua cov tswv yim thiab tso tawm rau 16-ntsis Unicode. Txawm hais tias muaj ntau chav kawm ntsig txog tus cwj pwm ntws tab sis cov chav kawm siv feem ntau yog, FileReader thiab FileWriter.

Hais txog qhov no, vim li cas Java siv I O ntws?

Java Kuv/ O kwj is kev khiav ntawm cov ntaub ntawv uas koj ua tau los yog nyeem los ntawm, los yog koj ua tau sau rau. Nws yog siv los ua kev nyeem thiab sau cov haujlwm hauv cov ntaub ntawv mus tas li. Java siv cov kwj deg los ua cov haujlwm no. Java .io pob muab cov chav kawm rau kev tawm tswv yim thiab tso tawm los ntawm cov ntaub ntawv, network ntws , nco buffers, thiab lwm yam.

Stream piav qhia ntau hom kwj dej yog dab tsi?

Ob qhov tseem ceeb hom dej ntws yog sau ntws thiab nyeem ntawv ntws . Thaum sau ntawv ntws sau cov ntaub ntawv rau hauv qhov chaw (cov ntaub ntawv), nyeem ntawv ntws yog siv los nyeem cov ntaub ntawv los ntawm ib qhov chaw (file). Lub pob java.io muaj ntau tus cov chav kawm ntws uas muaj peev xwm ua tau txhua yam hom ntawm cov ntaub ntawv.

Pom zoo: