Question: why throws ioexception in java?
Answer: The reason that you need to do something about the IOException is that it is a checked exception. If you call a constructor or a function that throws a checked exception then you either need to handle it, by catching it and taking appropriate actions.