第十五章输入输出 ■课程内容:流类、外部文件处理、数据流、打 印流、JFileChooser.、缓冲流、文本输入输出、 随机文件处理 ■授课时间:2006/06/08 ■教学目标:了解和掌握流式输入输出与文件处 理 ■了 重点:流式输入输出,文件处理等 ■教学方法:讲授 教学过程:(省略) ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. 课程内容:流类、外部文件处理、数据流、打 印流、JFileChooser、缓冲流、文本输入输出、 随机文件处理 授课时间:2006/06/08 教学目标:了解和掌握流式输入输出与文件处 理 重点:流式输入输出,文件处理等 教学方法:讲授 教学过程:(省略) 第十五章 输入输出
数据流 数据流是连续单路流动数据的抽象 输入数据流 程序 文件 输出数据流 ©2006计算机系杨群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. 数据流 数据流是连续单路流动数据的抽象 程序 输出数据流 文件 输入数据流
数据流的类 数据流类分为两种类型:字节流和字符流 InputStream/0 utputStream类是所有字节流 类的基类,Reader/,Writer类是所有字符流 的基类。InputStream/ OutputStream的子类与Reader,/Writer的子 类非常相似 ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. 数据流的类 数据流类分为两种类型:字节流和字符流 InputStream/OutputStream 类是所有字节流 类的基类,Reader/Writer 类是所有字符流 的基类。 InputStream/ OutputStream 的子类与Reader/Writer 的子 类非常相似
字节流类 ByteArrayInputStream DataInputStream InputData FilelnputStream BufferedInputStream FilterInputStream LineNumberInputStream InputStream SequencelnputStream PushBackInputStream PipedInputStream ObjectInputStream ObjectInput Object StringBufferInputStream ByteArrayOutputStream FileOutputStream BufferedOutputStream OutputStream FilterOutputStream DataOutputStream OutputData PipeOutputStream PrintStream ObjectOutputStream ObjectOutput RandomAccessFile ©2006计算机系杨厚群 All rights&lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. 字节流类 InputStream OutputStream RandomAccessFile Object PipeOutputStream SequenceInputStream StringBufferInputStream ByteArrayOutputStream ObjectOutputStream FilterOutputStream FileOutputStream PipedInputStream PushBackInputStream BufferedInputStream LineNumberInputStream DataInputStream BufferedOutputStream DataOutputStream PrintStream ObjectInputStream FilterInputStream FileInputStream ByteArrayInputStream InputData OutputData ObjectOutput ObjectInput
字符流类 CharArrayReader InputStreamReader FileReader FilterReader PushBackReader Reader StringReader PipedReader BufferedReader LineNumberReader BufferedWriter CharArrayWriter OutputStreamWriter FileWriter Writer FilterWriter PipedWriter PrintWriter StringWriter StreamTokenizer ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. 字符流类 Reader Writer StreamTokenizer Object PrintWriter BufferedWriter CharArrayWriter PipedWriter FilterWriter PipedReader LineNumberReader FileReader PushBackReader FileWriter StringWriter StringReader InputStreamReader CharArrayReader BufferedReader FilterReader OutputStreamWriter
nputStream类 abstract int read()throws IOException int read(byte b[])throws IOException void close()throws IOException void available()throws IOException void skip()throws IOException ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. InputStream类 abstract int read() throws IOException int read(byte b[]) throws IOException void close() throws IOException void available() throws IOException void skip() throws IOException
Reader类 Reader类与InputStream类似。在Reader类中的 方法处理的是字符 abstract int read()throws IOException int read (char b[])throws IOException void close()throws IOException void skip(throws IOException ©2006计算机系杨厚群 All rights &lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. Reader类 Reader类与InputStream类似。 在Reader类中的 方法处理的是字符 abstract int read() throws IOException int read(char b[]) throws IOException void close() throws IOException void skip() throws IOException
OutputStream类 abstract void write(int b)throws IOException void write(byte [b)throws IOException void close()throws IOException void flush()throws IOException ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. OutputStream类 abstract void write(int b) throws IOException void write(byte[] b) throws IOException void close() throws IOException void flush() throws IOException
Writera类 abstract void write(int b)throws IOException void write(char [b)throws IOException void close()throws IOException void flushO throws IOException ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. Writer类 abstract void write(int b) throws IOException void write(char[] b) throws IOException void close() throws IOException void flush() throws IOException