
InvalidObjectException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.io.IOException |—|—|—|—java.io.ObjectStreamException |—|—|—|—|—java.io.InvalidObjectException public class InvalidObjectException extends ObjectStreamException 表示一个或多个反序列化对象未通过验证测试。 论据应提供失败的原因。 Since: JDK1.1, JDK1.1 构造函数摘要 构造函数 描述 InvalidObjectException(String reason) 构造一个 InvalidObjectException。 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString 构造函数详细信息 InvalidObjectException public InvalidObjectException(String reason) 构造一个 InvalidObjectException。 参数: 参数名称 参数描述 reason 解释失败原因的详细消息。

InvalidClassException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.io.IOException |—|—|—|—java.io.ObjectStreamException |—|—|—|—|—java.io.InvalidClassException public class InvalidClassException extends ObjectStreamException 当序列化运行时检测到类的以下问题之一时引发。 类的串行版本与从流中读取的类描述符的版本不匹配 该类包含未知数据类型 该类没有可访问的无参数构造函数 Since: JDK1.1 字段摘要 修饰符和类型 字段 描述 String classname 无效类的名称。 构造函数摘要 构造函数 描述 InvalidClassException(String reason) 由于指定的原因报告 InvalidClassException。 InvalidClassException(String cname, String reason) 构造一个 InvalidClassException 对象。 方法总结 修饰符和类型 方法 描述 String getMessage() 生成消息并包含类名(如果存在)。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString 字段详细信息 classname public String classname 无效类的名称。 构造函数详细信息 InvalidClassException public InvalidClassException(String reason) 由于指定的原因报告 InvalidClassException。 参数: 参数名称 参数描述 reason 描述异常原因的字符串。 InvalidClassException public InvalidClassException(String cname, String reason) 构造一个 InvalidClassException 对象。 参数: 参数名称 参数描述 cname 一个命名无效类的字符串。 reason 描述异常原因的字符串。 方法详情 getMessage public String getMessage() 生成消息并包含类名(如果存在)。 覆盖: 类 Throwable 中的 getMessage 返回: 此 Throwable 实例的详细消息字符串(可能为 null)。

InterruptedIOException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.io.IOException |—|—|—|—java.io.InterruptedIOException public class InterruptedIOException extends IOException 表示 I/O 操作已被中断。 抛出 InterruptedIOException 以指示输入或输出传输已终止,因为执行它的线程被中断。 字段 bytesTransferred 指示在中断发生之前成功传输了多少字节。 Since: JDK1.0 字段摘要 修饰符和类型 字段 描述 int bytesTransferred 报告在中断之前作为 I/O 操作的一部分传输了多少字节。 构造函数摘要 构造函数 描述 InterruptedIOException() 构造一个带有 null 作为其错误详细消息的 InterruptedIOException。 InterruptedIOException(String s) 构造带有指定详细消息的 InterruptedIOException。 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString 字段详细信息 bytesTransferred public int bytesTransferred 报告在中断之前作为 I/O 操作的一部分传输了多少字节。 构造函数详细信息 InterruptedIOException public InterruptedIOException() 构造一个带有 null 作为其错误详细消息的 InterruptedIOException。 InterruptedIOException public InterruptedIOException(String s) 构造带有指定详细消息的 InterruptedIOException。 字符串 s 可以稍后通过 java.lang.Throwable 类的 Throwable.getMessage() 方法检索。 参数: 参数名称 参数描述 s 详细信息。

FileNotFoundException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.io.IOException |—|—|—|—java.io.FileNotFoundException public class FileNotFoundException extends IOException 表示尝试打开由指定路径名表示的文件失败的信号。 当具有指定路径名的文件不存在时,FileInputStream、FileOutputStream 和 RandomAccessFile 构造函数将引发此异常。 如果文件确实存在但由于某种原因不可访问,例如当试图打开只读文件进行写入时,这些构造函数也会抛出它。 Since: JDK1.0 构造函数摘要 构造函数 描述 FileNotFoundException() 构造一个以 null 作为其错误详细消息的 FileNotFoundException。 FileNotFoundException(String s) 使用指定的详细消息构造 FileNotFoundException。 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString 构造函数详细信息 FileNotFoundException public FileNotFoundException() 构造一个以 null 作为其错误详细消息的 FileNotFoundException。 FileNotFoundException public FileNotFoundException(String s) 使用指定的详细消息构造 FileNotFoundException。 字符串 s 可以稍后通过 java.lang.Throwable 类的 Throwable.getMessage() 方法检索。 参数: 参数名称 参数描述 s 详细信息。

EOFException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.io.IOException |—|—|—|—java.io.EOFException public class EOFException extends IOException 表示输入期间意外到达文件结尾或流结尾。 此异常主要由数据输入流用来表示流结束。 请注意,许多其他输入操作在流结束时返回一个特殊值,而不是引发异常。 Since: JDK1.0 构造函数摘要 构造函数 描述 EOFException() 构造一个以 null 作为其错误详细消息的 EOFException。 EOFException(String s) 构造带有指定详细消息的 EOFException。 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString 构造函数详细信息 EOFException public EOFException() 构造一个以 null 作为其错误详细消息的 EOFException。 EOFException public EOFException(String s) 构造带有指定详细消息的 EOFException。 字符串 s 可以稍后由 java.lang.Throwable 类的 Throwable.getMessage() 方法检索。 参数: 参数名称 参数描述 s 详细信息。

CharConversionException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.io.IOException |—|—|—|—java.io.CharConversionException public class CharConversionException extends IOException 字符转换异常的基类。 Since: JDK1.1 构造函数摘要 构造函数 描述 CharConversionException() 这没有提供详细信息。 CharConversionException(String s) 这提供了详细的消息。 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString 构造函数详细信息 CharConversionException public CharConversionException() 这没有提供详细信息。 CharConversionException public CharConversionException(String s) 这提供了详细的消息。 参数: 参数名称 参数描述 s 与异常相关的详细消息。

Writer java.lang.Object |—java.io.Writer public abstract class Writer extends Object implements Appendable, Closeable, Flushable 用于写入字符流的抽象类。 子类必须实现的唯一方法是 write(char[], int, int)、flush() 和 close()。 然而,大多数子类将覆盖此处定义的一些方法,以提供更高的效率、附加功能或两者兼而有之。 Since: JDK1.1 字段摘要 修饰符和类型 字段 描述 protected Object lock 用于同步此流上的操作的对象。 构造函数摘要 修饰符 构造函数 描述 protected Writer() 创建一个新的字符流编写器,其关键部分将在编写器本身上同步。 protected Writer(Object lock) 创建一个新的字符流编写器,其关键部分将在给定对象上同步。 方法总结 修饰符和类型 方法 描述 Writer append(char c) 将指定的字符附加到这个 writer。 Writer append(CharSequence csq) 将指定的字符序列附加到此编写器。 Writer append(CharSequence csq, int start, int end) 将指定字符序列的子序列附加到此编写器。 abstract void close() 关闭流,首先刷新它。 abstract void flush() 冲洗流。 void write(char[] cbuf) 写入一个字符数组。 abstract void write(char[] cbuf, int off, int len) 写入字符数组的一部分。 void write(int c) 写入单个字符。 void write(String str) 写入一个字符串。 void write(String str, int off, int len) 写入字符串的一部分。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 字段详细信息 lock protected Object lock 用于同步此流上的操作的对象。 为了提高效率,字符流对象可以使用自身以外的对象来保护临界区。 因此,子类应该使用该字段中的对象而不是 this 或同步方法。 构造函数详细信息 Writer protected Writer() 创建一个新的字符流编写器,其关键部分将在编写器本身上同步。 Writer protected Writer(Object lock) 创建一个新的字符流编写器,其关键部分将在给定对象上同步。 参数: 参数名称 参数描述 lock 要同步的对象 方法详情 write public void write(int c) throws IOException 写入单个字符。 要写入的字符包含在给定整数值的低 16 位中; 16 个高位被忽略。 打算支持高效单字符输出的子类应覆盖此方法。 参数: 参数名称...

StringWriter java.lang.Object |—java.io.Writer |—|—java.io.StringWriter public class StringWriter extends Writer 在字符串缓冲区中收集其输出的字符流,然后可用于构造字符串。 关闭 StringWriter 无效。 可以在流关闭后调用此类中的方法,而不会生成 IOException。 Since: JDK1.1 字段摘要 从类 java.io.Writer 继承的字段 lock 构造函数摘要 构造函数 描述 StringWriter() 使用默认的初始字符串缓冲区大小创建一个新的字符串编写器。 StringWriter(int initialSize) 使用指定的初始字符串缓冲区大小创建一个新的字符串编写器。 方法总结 修饰符和类型 方法 描述 StringWriter append(char c) 将指定的字符附加到这个 writer。 StringWriter append(CharSequence csq) 将指定的字符序列附加到此编写器。 StringWriter append(CharSequence csq, int start, int end) 将指定字符序列的子序列附加到此编写器。 void close() 关闭 StringWriter 无效。 void flush() 冲洗流。 StringBuffer getBuffer() 返回字符串缓冲区本身。 String toString() 将缓冲区的当前值作为字符串返回。 void write(char[] cbuf, int off, int len) 写入字符数组的一部分。 void write(int c) 写一个字符。 void write(String str) 写一个字符串。 void write(String str, int off, int len) 写一个字符串的一部分。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.io.Writer 继承的方法 write 构造函数详细信息 StringWriter public StringWriter() 使用默认的初始字符串缓冲区大小创建一个新的字符串编写器。 StringWriter public StringWriter(int initialSize) 使用指定的初始字符串缓冲区大小创建一个新的字符串编写器。 参数: 参数名称 参数描述 initialSize 在自动扩展之前将适合此缓冲区的 char 值的数量 Throws: Throw名称 Throw描述 IllegalArgumentException 如果 initialSize 为负数 方法详情 write public void write(int c) 写一个字符。 覆盖: 在 Writer 类中写 参数: 参数名称 参数描述 c int 指定要写入的字符 write public void write(char[] cbuf, int off, int len) 写入字符数组的一部分。...

StringReader java.lang.Object |—java.io.Reader |—|—java.io.StringReader public class StringReader extends Reader 源为字符串的字符流。 Since: JDK1.1 字段摘要 从类 java.io.Reader 继承的字段 lock 构造函数摘要 构造函数 描述 StringReader(String s) 创建一个新的字符串阅读器。 方法总结 修饰符和类型 方法 描述 void close() 关闭流并释放与其关联的任何系统资源。 void mark(int readAheadLimit) 标记流中的当前位置。 boolean markSupported() 告诉这个流是否支持 mark() 操作,它支持。 int read() 读取单个字符。 int read(char[] cbuf, int off, int len) 将字符读入数组的一部分。 boolean ready() 告诉这个流是否准备好被读取。 void reset() 将流重置为最近的标记,如果从未标记过,则重置为字符串的开头。 long skip(long ns) 跳过流中指定数量的字符。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 从类 java.io.Reader 继承的方法 read, read 构造函数详细信息 StringReader public StringReader(String s) 创建一个新的字符串阅读器。 参数: 参数名称 参数描述 s 提供字符流的字符串。 方法详情 read public int read() throws IOException 读取单个字符。 覆盖: read in class Reader 返回: 读取的字符,如果已到达流的末尾,则为 -1 Throws: Throw名称 Throw描述 IOException 如果发生 I/O 错误 read public int read(char[] cbuf, int off, int len) throws IOException 将字符读入数组的一部分。 指定者: read in class Reader 参数: 参数名称 参数描述 cbuf 目标缓冲区 off 开始写入字符的偏移量 len 要读取的最大字符数 返回: 读取的字符数,如果已到达流的末尾,则为 -1 Throws:...

StringBufferInputStream java.lang.Object |—java.io.InputStream |—|—java.io.StringBufferInputStream @Deprecated public class StringBufferInputStream extends InputStream 已弃用。 此类没有正确地将字符转换为字节。 从 JDK 1.1 开始,从字符串创建流的首选方法是通过 StringReader 类。 Since: JDK1.0 字段摘要 修饰符和类型 字段 描述 protected String buffer 已弃用。 从中读取字节的字符串。 protected int count 已弃用。 输入流缓冲区中的有效字符数。 protected int pos 已弃用。 要从输入流缓冲区读取的下一个字符的索引。 构造函数摘要 构造函数 描述 StringBufferInputStream(String s) 已弃用。 创建一个字符串输入流以从指定的字符串中读取数据。 方法总结 修饰符和类型 方法 描述 int available() 已弃用。 返回可以从输入流中读取而不阻塞的字节数。 int read() 已弃用。 从此输入流中读取数据的下一个字节。 int read(byte[] b, int off, int len) 已弃用。 从此输入流中读取最多 len 个字节的数据到一个字节数组中。 void reset() 已弃用。 重置输入流以从该输入流的底层缓冲区的第一个字符开始读取。 long skip(long n) 已弃用。 从此输入流中跳过 n 个字节的输入。 从类 java.io.InputStream 继承的方法 close, mark, markSupported, read 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 字段详细信息 buffer protected String buffer 已弃用。 从中读取字节的字符串。 count protected int count 已弃用。 输入流缓冲区中的有效字符数。 pos protected int pos 已弃用。 要从输入流缓冲区读取的下一个字符的索引。 构造函数详细信息 StringBufferInputStream public StringBufferInputStream(String s) 已弃用。 创建一个字符串输入流以从指定的字符串中读取数据。 参数: 参数名称 参数描述 s 底层输入缓冲区。 方法详情 read public int read() 已弃用。 从此输入流中读取数据的下一个字节。 值字节作为 int 返回,范围为 0 到 255。如果由于到达流的末尾而没有可用的字节,则返回值 -1。 StringBufferInputStream 的读取方法不能阻塞。 它返回此输入流缓冲区中下一个字符的低八位。 指定者: 读入类 InputStream 返回: 数据的下一个字节,如果到达流的末尾,则为 -1。 read...