1、System.in
2、缓冲流
3、对象序列化
public static final InputStream in
只是现在不是像之前那样是从文件中读了,而是从键盘上读数据了。
首先程序开辟了一段空间,如果现在假设输入的内容大于开辟的空间,那会如何呢?
最好的解决方法是设置一个缓冲区,所有的内容放到缓冲区中一次性读出来。
此缓冲区最好是为字符缓冲区 —— BufferedReader
public BufferedReader(Reader in)
此处必须接收一个Reader的对象,但是System.in实际上是InputStream类的对象
· 在物理上存放的肯定永远是字节流
· 读到程序之中才会形成字符流
· ObjectOutputStream
· ObjectInputStream
只是一个标识接口,表示你这个类的对象允许被序列化
ObjectOutputStream类的构造方法,接收一个OutputStream类的实例化对象,以表示到底向那里保存。
public final void writeObject(Object obj) throws IOException
public final Object readObject() throws IOException,ClassNotFoundException
OutputStream:字节的输出流类
|- FileOutputStream
|- ObjectOutputStream
|- ByteArrayOutputStream
|- PipedOutputStream
|- PrintStream
InputStream:字节的输入流类
|- FileInputStream
|- ObjectInputStream
|- ByteArrayInputStream
|- PipedInputStream
Reader:字符流的输入类
|- InputStreamReader
|- FileReader
|- BufferedReader
Writer:字符流的输出类
|- OutputStreamWriter
|- FileWriter
|- PrintWirter
File类:
Serializable接口
hema0214 2011-11-23
waterfly 2009-03-04
yzzh9 2009-03-02
redking 博主 回复了 yzzh9 2009-03-02