1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. Oracle designates this 9 * particular file as subject to the "Classpath" exception as provided 10 * by Oracle in the LICENSE file that accompanied this code. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 */ 26 27 package java.io; 28 29 /** 30 * Signals that an I/O operation has been interrupted. An 31 * {@code InterruptedIOException} is thrown to indicate that an 32 * input or output transfer has been terminated because the thread 33 * performing it was interrupted. The field {@link #bytesTransferred} 34 * indicates how many bytes were successfully transferred before 35 * the interruption occurred. 36 * 37 * @see java.io.InputStream 38 * @see java.io.OutputStream 39 * @see java.lang.Thread#interrupt() 40 * @since 1.0 41 */ 42 public class InterruptedIOException extends IOException { 43 @java.io.Serial 44 private static final long serialVersionUID = 4020568460727500567L; 45 46 /** 47 * Constructs an {@code InterruptedIOException} with 48 * {@code null} as its error detail message. 49 */ InterruptedIOException()50 public InterruptedIOException() { 51 super(); 52 } 53 54 /** 55 * Constructs an {@code InterruptedIOException} with the 56 * specified detail message. The string {@code s} can be 57 * retrieved later by the 58 * {@link java.lang.Throwable#getMessage} 59 * method of class {@code java.lang.Throwable}. 60 * 61 * @param s the detail message. 62 */ InterruptedIOException(String s)63 public InterruptedIOException(String s) { 64 super(s); 65 } 66 67 /** 68 * Reports how many bytes had been transferred as part of the I/O 69 * operation before it was interrupted. 70 * 71 * @serial 72 */ 73 public int bytesTransferred = 0; 74 75 // Android-added: Additional constructor for internal use. 76 /** @hide */ InterruptedIOException(Throwable cause)77 public InterruptedIOException(Throwable cause) { 78 super(cause); 79 } 80 81 // Android-added: Additional constructor for internal use. 82 /** 83 * Constructs a new instance with given detail message and cause. 84 * 85 * @hide internal use only 86 */ InterruptedIOException(String detailMessage, Throwable cause)87 public InterruptedIOException(String detailMessage, Throwable cause) { 88 super(detailMessage, cause); 89 } 90 } 91