File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,7 +70,9 @@ Java核心技术学习代码兼测试案例<br>
7070 ├── MemoryInputT.java // 内存中输入
7171 ├── PipeStreamT.java // 管道输入输出流的的使用
7272 ├── RandomAccessFileT.java // RandomAccessFile的使用
73+ ├── StoringAndRecoveringData.java // DataOutputStream和DataInputStream的使用案例
7374 ├── SystemStreamT.java // System.out, System.err中IO的使用
75+ ├── UsingRandomAccessFile.java // RandomAccessFile的使用案例
7476 ├── org.javacore.io.byteoper // Java IO 字节操作
7577 ├── IntegerConvertT.java // Integer与byte数组转换
7678 ├── IntegerOperT.java // Integer类的进制转换
Original file line number Diff line number Diff line change 1+ package org .javacore .io ;
2+
3+ import java .io .Closeable ;
4+ import java .io .Flushable ;
5+ import java .io .IOException ;
6+
7+ /**
8+ * 所有字节输出流实现类的基类
9+ */
10+ public abstract class SOutputStream implements Closeable , Flushable {
11+
12+ // 将指定的字节写入输出流
13+ public abstract void write (int b ) throws IOException ;
14+
15+ // 将指定的byte数组的字节全部写入输出流
16+ public void write (byte b []) throws IOException {
17+ write (b , 0 , b .length );
18+ }
19+
20+ // 将指定的byte数组中从偏移量off开始的len个字节写入输出流
21+ public void write (byte b [], int off , int len ) throws IOException {
22+ if (b == null ) {
23+ throw new NullPointerException ();
24+ } else if ((off < 0 ) || (off > b .length ) || (len < 0 ) ||
25+ ((off + len ) > b .length ) || ((off + len ) < 0 )) {
26+ throw new IndexOutOfBoundsException ();
27+ } else if (len == 0 ) {
28+ return ;
29+ }
30+ for (int i = 0 ; i < len ; i ++) {
31+ write (b [off + i ]);
32+ }
33+ }
34+
35+ // 刷新输出流,并强制写出所有缓冲的输出字节
36+ public void flush () throws IOException {
37+ }
38+
39+ // 关闭输出流,并释放与该流有关的所有资源
40+ public void close () throws IOException {
41+ }
42+
43+ }
You can’t perform that action at this time.
0 commit comments