본문 바로가기
컴퓨터공학/Java

error: exception IOException is never thrown in body of corresponding try statement 에러

by 무에서 2017. 8. 19.
반응형

Java에서 처리하는 예외의 종류는 매우 많다. 그 중에서 사용된 IOException가 적합하지 않을 때 "error: exception IOException is never thrown in body of corresponding try statement" 에러가 발생한다.


예를 들면 Integer.parseInt에는 다음 코드와 같이 NumberFormatException를 사용해야 한다. IOException을 사용하면 위와 같은 에러가 뜬다.


try{

i = Integer.parseInt(s);

} catch (NumberFormatException e) {

}


'Exception'은 종류에 상관없이 모든 예외에 사용할 수 있다.



예외의 종류는 다음과 같다.

AclNotFoundException, ActivationException, AlreadyBoundException, ApplicationException, AWTException, BackingStoreException, BadAttributeValueExpException, BadBinaryOpValueExpException, BadLocationException, BadStringOperationException, BrokenBarrierException, CertificateException, CloneNotSupportedException, DataFormatException, DatatypeConfigurationException, DestroyFailedException, ExecutionException, ExpandVetoException, FontFormatException, GeneralSecurityException, GSSException, IllegalClassFormatException, InterruptedException, IntrospectionException, InvalidApplicationException, InvalidMidiDataException, InvalidPreferencesFormatException, InvalidTargetObjectTypeException, IOException, JAXBException, JMException, KeySelectorException, LastOwnerException, LineUnavailableException, MarshalException, MidiUnavailableException, MimeTypeParseException, MimeTypeParseException, NamingException, NoninvertibleTransformException, NotBoundException, NotOwnerException, ParseException, ParserConfigurationException, PrinterException, PrintException, PrivilegedActionException, PropertyVetoException, ReflectiveOperationException, RefreshFailedException, RemarshalException, RuntimeException, SAXException, ScriptException, ServerNotActiveException, SOAPException, SQLException, TimeoutException, TooManyListenersException, TransformerException, TransformException, UnmodifiableClassException, UnsupportedAudioFileException, UnsupportedCallbackException, UnsupportedFlavorException, UnsupportedLookAndFeelException, URIReferenceException, URISyntaxException, UserException, XAException, XMLParseException, XMLSignatureException, XMLStreamException, XPathException


반응형

댓글