Cov txheej txheem:

Qhov kev zam IO yog dab tsi?
Qhov kev zam IO yog dab tsi?

Video: Qhov kev zam IO yog dab tsi?

Video: Qhov kev zam IO yog dab tsi?
Video: Hi So - Koj haib 2 (Official MV nkauj tawm tshiab 2019-2020) 2024, Kaum ib hlis
Anonim

IOException yog ib kev zam uas programmers siv nyob rau hauv cov cai mus pov ib tug tsis ua hauj lwm nyob rau hauv lub tswv yim & Output ua hauj lwm. Nws yog ib qho kev kuaj xyuas kev zam . Tus programmer yuav tsum tau subclass IOException thiab yuav tsum pov lub IOException subclass raws li cov ntsiab lus.

Ib yam li ntawd, tib neeg nug, qhov kev zam IO txhais li cas?

Raws li kuv qhov kev paub txog kev ua haujlwm ntawm Programming IOException siv hauv Java txhais tau tias Input Output Exception uas nyob rau hauv luv luv txhais tau hais tias cov tswv yim ntawm koj cov cai ua tsis zoo li yuav aligning nrog cov zis Nws yeej yog ib hom ntawm yuam kev tuav uas qhia lub compiler ntawm koj cov cai hais tias qhov kev pab cuam muaj cov khoom uas tej zaum yuav pov

Kuj Paub, thaum IO kev zam tshwm sim hauv Java? Java IOExceptions yog Input/Output exceptions (I/O), thiab lawv tshwm sim thaum twg ib qho kev tawm tswv yim lossis kev ua haujlwm tawm tsis ua tiav lossis txhais. Piv txwv li, yog tias koj tab tom sim nyeem hauv cov ntaub ntawv uas tsis muaj nyob, Java yuav pov ib I/O kev zam.

Hauv qhov no, dab tsi ua rau muaj kev zam IO?

Nws tuaj yeem pov ib qho IOException thaum twg tus kwj nws tus kheej yog corrupted los yog ib co yuam kev tshwm sim thaum nyeem cov ntaub ntawv xws li kev ruaj ntseg Kev zam , Tso Cai Tsis Pom Zoo thiab lwm yam thiab / lossis ib txheej ntawm Kev zam uas yog muab los ntawm IOEXception.

Koj pov IO kev zam li cas?

B) Qhov kev pab cuam yog tias muaj kev zam

  1. import java.io.*;
  2. chav kawm M {
  3. void method() pov IOException{
  4. pov tshiab IOException("device yuam kev");
  5. }
  6. }
  7. chav Testthrows4{
  8. pej xeem static void main(String args) pov IOException{//declare exception.

Pom zoo: