Java.IO note
2015-11-29 20:45
525 查看
Java.IO
File Class:
Path Interface and Files Class is part of NIO System.AutoCloseable, Closeable, Flushable Interface
Closeable, Flushable is part of java.ioAutoCloseable is part of java.lang
Only Class implemented AutoCloseable Interface can deal with try statement
I/O Exception:
IOExceptionSecurityException (most on applet)
Close Stream:
close()try-with-resources:
Must implement AutoCloseable Interface
Resource in try statement is declared as final
Use “;” can deal multi-resource
ByteStream
过滤的字节流:这些流一般是通过接收通用流的方法访问的,通用流是过滤流的超类。
BufferedInputStream/BufferedOutputStream
PushbackInputStream:
void unread(int b)void unread(byte buf[])
void unread(byte buffer, iint offset, iint numBytes)
PushbackInputStream Object will make InputStream Object be Unsupported to mark() and reset(). For any Stream using mark() and reset(), should use markSupported() method first to check.
SequenceInputStream
PrintStream:
Implemented Interface Appendable, AutoCloseable, Closeable, Flushableprintf() / format()
DataInputStream / DataOutputStream:
Write fundamental data type into StreamImplemented Interface Appendable, AutoCloseable, Closeable, Flushable
RandomAccessFile:
Implemented Interface DataInput and DataOutput, AutoCloseable and Closeable.void seek(long newPos) throws IOException
void setLength(long len) throws IOException
CharStream
Reader:
Implemented Interface AutoCloseable, Closeable, ReadableWriter:
Implemented Interface AutoCloseable, Closeable, Flushable, AppendableConsole
In java.ioNo constructor method, use System.console() obtain the Object
Method throws IOError: String readLine(), char[] readPassword.
IOError can not be catched, so it means a disaster to System.
串行化
串行化是将对象的状态写入字节流的过程。Interface Seralizable
只有实现了此借口的类才能通过串行化功能进行板寸和恢复。此借口没有定义成员,只是用于指示可串行化。如果一个类是可串行化的,它的子类也是。声明为transient的变量不能通过串行化功能进行保存,也不能保存static变量。
Interface Externalizable
ObjectOutput implements DataOutput, AutoCloseable
ObjectOutputStream
ObjectInput implements DataInput, AutoCloseable
ObjectInputStream implements ObjectInput
相关文章推荐
- 【Eclipse for IAR】使用 Eclipse 编写 IAR 程序
- 操作系统概念 管程Java代码实现
- java+struts+spring验证用户名是否存在
- Java数据库操作
- 今天 java第一课
- 今天来打打java大数模板(整型)
- 关于JavaWeb和mysql中文乱码的经验
- java处理csv文件
- 通过利用引用型数据和基本型数据的区别可以判断出数据的类型是否是引用型的String为例
- 黑马程序员--Eclipse的基本操作(我们的课堂练习)
- Java递归应用:输出树形菜单
- Java语法基础
- javaSE(11)(集合迭代器与比较器)
- java多线程(学习笔记)
- 安装卸载openjdk&&sunjdk
- java抢红包功能实现
- Java集合中TreeSet的实现原理
- Java移位运算符详解实例——左移位运算符>>、带符号的右移位运算符>>
- 如何快速从Eclipse转向IDEA
- JAVA基本语言、语法基础(二)未完成