• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IOException

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Why java.io.IOException must be caught or declared to be thrown when i work whith I/O package?
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jordi,
It is because IOException is a checked exception.
Regards
Gurpreet Sachdeva
For Mock Exams and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: http://www.go4java.20m.com
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jordi
The obvious answer is because a lot of the I/O methods can throw that exception, so you must catch ot or re-throw it for your code to compile.
If your asking why do they throw these exceptions then it is most likely because there are numerous reasons that I/O can fail (bad file names, bad paths, and any number of other reasons). The system has to have some way of letting you know that, for one reason or another, what you were trying to do has failed. If it didn't you'd never know if it was your code, the disk, a bad name, etc...
not sure if that answered your question
let me know if not

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
 
I don't even know how to spell CIA. But this tiny ad does:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic