Puas muaj () hauv Java?
Puas muaj () hauv Java?

Video: Puas muaj () hauv Java?

Video: Puas muaj () hauv Java?
Video: Koos Vaj - Puas Muaj Tshuaj Kho Kev Hlub 2024, Kaum ib hlis
Anonim

Cov muaj () txoj kev yog ib tug built-in txoj kev ntawm lub Java . io ib. ByteArrayInputStream rov qab cov lej ntawm cov bytes uas tseem tuaj yeem nyeem tau (lossis hla dhau) los ntawm cov dej nkag no. ntawm bytes los ntawm Input Stream yuav tsum tau nyeem.

Tom qab ntawd, ib tug kuj yuav nug, dab tsi yog nyeem () hauv Java?

Cov java ua . io ib. InputStream. nyeem() txoj kev nyeem tom ntej byte ntawm cov ntaub ntawv los ntawm cov kwj nkag thiab xa rov qab int hauv thaj tsam ntawm 0 txog 255. Yog tias tsis muaj byte vim tias qhov kawg ntawm cov kwj tau mus txog, tus nqi rov qab yog -1.

Tsis tas li ntawd, BufferedReader yog dab tsi hauv Java? Vim li cas siv BufferedReader thiab BufferedWriter Classses hauv Java . BufferedReader yog chav kawm hauv Java uas nyeem cov ntawv los ntawm tus cwj pwm-input kwj, buffering cov cim thiaj li muab kev nyeem ntawv zoo ntawm cov cim, kab thiab arrays. Qhov loj tsis tuaj yeem raug teev tseg.

Ua kom qhov no saib, dab tsi yog qhov input kwj Java?

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. Cov InputStream yog siv los nyeem cov ntaub ntawv los ntawm ib qhov chaw thiab OutputStream yog siv los sau cov ntaub ntawv mus rau qhov chaw. Ntawm no yog ib tug hierarchy ntawm cov chav kawm los nrog Tswv yim thiab Tso zis ntws.

Dab tsi yog cov subclasses ncaj qha ntawm InputStream?

Ib tug input kwj nrog ib tug teev lub hom ntawv thiab ntev.

  • ByteArrayInputStream.
  • FileInputStream.
  • FilterInputStream.
  • ObjectInputStream.
  • PipedInputStream.
  • SequenceInputStream.
  • StringBufferInputStream.
  • Pom zoo: