Cov txheej txheem:

Nrhiav hauv Java yog dab tsi?
Nrhiav hauv Java yog dab tsi?

Video: Nrhiav hauv Java yog dab tsi?

Video: Nrhiav hauv Java yog dab tsi?
Video: XENGYANG - NWS YOG DAB TSIS (WHAT'S MEANS) [Official Music Audio] 2024, Kaum ib hlis
Anonim

Cov java ua . io ib. RandomAccessFile. nrhiav (ntev pos) txoj kev teeb tsa cov ntaub ntawv-pointer offset, ntsuas los ntawm qhov pib ntawm cov ntaub ntawv no, uas tom ntej nyeem lossis sau tshwm sim. Qhov ntev ntawm cov ntaub ntawv yuav hloov tsuas yog los ntawm kev sau ntawv tom qab qhov offset tau teem dhau qhov kawg ntawm cov ntaub ntawv.

Kuj paub, RandomAccessFile yog dab tsi hauv Java?

Java - RandomAccessFile . Chav kawm no yog siv rau kev nyeem ntawv thiab sau ntawv rau random access file . A random nkag cov ntaub ntawv coj zoo li ib tug loj array ntawm bytes. Muaj tus cursor implied rau cov array hu ua file pointer, los ntawm kev txav tus cursor peb ua cov haujlwm nyeem ntawv.

Tom qab ntawd, lo lus nug yog, dab tsi yog random access file? Random - nkag mus rau cov ntaub ntawv yog ib lo lus siv los piav txog a ntaub ntawv los yog set ntawm cov ntaub ntawv uas nkag mus ncaj qha es tsis txhob xav kom lwm tus cov ntaub ntawv nyeem ua ntej. Khoos phis tawj hard drives nkag mus rau cov ntaub ntawv ncaj qha, qhov twg daim kab xev drives feem ntau nkag mus rau cov ntaub ntawv ua ntu zus. Ncaj nraim nkag mus , Hardware Terms, Sequential ntaub ntawv.

Tsis tas li ntawd, kuv yuav siv cov ntaub ntawv nkag mus li cas?

Java RandomAccessFile Piv txwv

  1. getFilePointer() kom tau txais txoj haujlwm tam sim no ntawm tus taw tes.
  2. nrhiav (int) los teeb tsa txoj hauj lwm ntawm tus pointer.
  3. read(byte b) nyeem mus txog b. ntev bytes ntawm cov ntaub ntawv los ntawm cov ntaub ntawv mus rau hauv ib tug array ntawm bytes.
  4. write(byte b) sau b. ntev bytes los ntawm qhov teev byte array rau cov ntaub ntawv, pib ntawm cov ntaub ntawv tam sim no pointer.

Cov ntaub ntawv hauv Java yog dab tsi?

Kev tshaj tawm. Java File chav kawm sawv cev rau cov ntaub ntawv thiab cov npe pathnames hauv kev paub daws teeb meem. Cov chav kawm no yog siv los tsim cov ntaub ntawv thiab cov npe, ntaub ntawv nrhiav, ntaub ntawv deletion, thiab lwm yam Cov ntaub ntawv khoom sawv cev qhov tseeb ntaub ntawv / directory ntawm lub disk.

Pom zoo: