1 /* 2 * Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.io; 27 28 /** 29 * Signals that an I/O exception of some sort has occurred. This 30 * class is the general class of exceptions produced by failed or 31 * interrupted I/O operations. 32 * 33 * @see java.io.InputStream 34 * @see java.io.OutputStream 35 * @since 1.0 36 */ 37 public class IOException extends Exception { 38 @java.io.Serial 39 static final long serialVersionUID = 7818375828146090155L; 40 41 /** 42 * Constructs an {@code IOException} with {@code null} 43 * as its error detail message. 44 */ IOException()45 public IOException() { 46 super(); 47 } 48 49 /** 50 * Constructs an {@code IOException} with the specified detail message. 51 * 52 * @param message 53 * The detail message (which is saved for later retrieval 54 * by the {@link #getMessage()} method) 55 */ IOException(String message)56 public IOException(String message) { 57 super(message); 58 } 59 60 /** 61 * Constructs an {@code IOException} with the specified detail message 62 * and cause. 63 * 64 * <p> Note that the detail message associated with {@code cause} is 65 * <i>not</i> automatically incorporated into this exception's detail 66 * message. 67 * 68 * @param message 69 * The detail message (which is saved for later retrieval 70 * by the {@link #getMessage()} method) 71 * 72 * @param cause 73 * The cause (which is saved for later retrieval by the 74 * {@link #getCause()} method). (A null value is permitted, 75 * and indicates that the cause is nonexistent or unknown.) 76 * 77 * @since 1.6 78 */ IOException(String message, Throwable cause)79 public IOException(String message, Throwable cause) { 80 super(message, cause); 81 } 82 83 /** 84 * Constructs an {@code IOException} with the specified cause and a 85 * detail message of {@code (cause==null ? null : cause.toString())} 86 * (which typically contains the class and detail message of {@code cause}). 87 * This constructor is useful for IO exceptions that are little more 88 * than wrappers for other throwables. 89 * 90 * @param cause 91 * The cause (which is saved for later retrieval by the 92 * {@link #getCause()} method). (A null value is permitted, 93 * and indicates that the cause is nonexistent or unknown.) 94 * 95 * @since 1.6 96 */ IOException(Throwable cause)97 public IOException(Throwable cause) { 98 super(cause); 99 } 100 } 101