40 |
class StreamInputStream extends DTPInputStream |
class StreamInputStream extends DTPInputStream |
41 |
{ |
{ |
42 |
|
|
43 |
StreamInputStream(DTP dtp, InputStream in) |
StreamInputStream(DTP dtp, InputStream in) |
44 |
{ |
{ |
45 |
super(dtp, in); |
super(dtp, in); |
46 |
} |
} |
47 |
|
|
48 |
|
public int read() throws IOException |
49 |
|
{ |
50 |
|
if (transferComplete) |
51 |
|
return -1; |
52 |
|
int c = in.read(); |
53 |
|
if (c == -1) |
54 |
|
close(); |
55 |
|
return c; |
56 |
|
} |
57 |
|
|
58 |
|
public int read(byte[] buf) throws IOException |
59 |
|
{ |
60 |
|
return read(buf, 0, buf.length); |
61 |
|
} |
62 |
|
|
63 |
public int read() throws IOException |
public int read(byte[] buf, int off, int len) throws IOException |
64 |
{ |
{ |
65 |
if (transferComplete) |
if (transferComplete) |
66 |
return -1; |
return -1; |
67 |
int c = super.read(); |
int l = in.read(buf, off, len); |
68 |
if (c == -1) |
if (l == -1) |
69 |
close(); |
close(); |
70 |
return c; |
return l; |
71 |
} |
} |
|
|
|
|
public int read(byte[]buf) throws IOException |
|
|
{ |
|
|
return read(buf, 0, buf.length); |
|
|
} |
|
|
|
|
|
public int read(byte[]buf, int off, int len) throws IOException |
|
|
{ |
|
|
if (transferComplete) |
|
|
return -1; |
|
|
int l = super.read(buf, off, len); |
|
|
if (l == -1) |
|
|
close(); |
|
|
return l; |
|
|
} |
|
72 |
|
|
73 |
} |
} |