Input Stream read File Reader int read int
- Slides: 14
Input. Stream类提供的方法 § 三个基本的read方法: File. Reader int read() int read(byte[] buffer, int offset, int length) § 其它方法: void close() int available() skip(long n) boolean mark. Supported() void mark(int readlimit) void reset()
Output. Stream类提供的方法 § 三个基本的write方法: void write(int c) void write(byte[] buffer, int offset, int length) § 其它方法 void close() void flush()
Reader类提供的方法 § 三个基本的read方法: int read() int read(char[] cbuf, int offset, int length) § 其它方法 void close() boolean ready() skip(long n) boolean mark. Supported() void mark(int read. Ahead. Limit) void reset()
Writer类提供的方法 § 三个基本的write方法: void write(int c) void write(char[] cbuf, int offset, int length) void write(String string, int offset, int length) § 其它方法 void close() void flush()
节点流类型(Node Streams) 类 型 字符流 字节流 File. Reader File. Writer File. Input. Stream File. Output. Stream Memory Array Char. Array. Reader Char. Array. Writer Byte. Array. Input. Stream Byte. Array. Output. Stream Memory String. Reader String. Writer Piped. Reader Piped. Writer Piped. Input. Stream Piped. Output. Stream
节点流应用举例--文件复制 import java. io. *; public class Test 1 { public static void main(String[] args) { try { File. Reader input = new File. Reader("Test 1. java"); File. Writer output = new File. Writer("temp. txt"); int read = input. read(); while ( read != -1 ) { output. write(read); read = input. read(); } input. close(); output. close(); } catch (IOException e) { System. out. println(e); } } }
缓冲功能处理流举例 import java. io. *; public class Test 2 { public static void main(String[] args) { try { File. Reader input = new File. Reader("Test 2. java"); Buffered. Reader br = new Buffered. Reader(input); File. Writer output = new File. Writer("temp. txt"); Buffered. Writer bw = new Buffered. Writer(output); String s = br. read. Line(); while ( s!=null ) { bw. write(s); bw. new. Line(); s = br. read. Line(); } br. close(); bw. close(); } catch (IOException e) { e. print. Stack. Trace(); } } }
- Sum0
- Public int divide(int a int b)
- Int max(int x int y)
- Inheritance calculator
- Public void drawsquare(int x, int y, int len)
- File-file yang dibuat oleh user pada jenis file di linux
- Differentiate byte stream and character stream
- Primavera assignment help
- Java 파일 복사 예제
- Xml file reader
- Xml file reader
- Xml file reader
- The randomaccessfile class treats a file as a stream of
- File stream object
- Google backup and sync vs file stream