1 |
/* |
/* |
2 |
* $Id$ |
* StreamInputStream.java |
3 |
* Copyright (C) 2003 The Free Software Foundation |
* Copyright (C) 2003 The Free Software Foundation |
4 |
* |
* |
5 |
* This file is part of GNU inetlib, a library. |
* This file is part of GNU inetlib, a library. |
46 |
* A DTP input stream that implements the FTP stream data transfer mode. |
* A DTP input stream that implements the FTP stream data transfer mode. |
47 |
* |
* |
48 |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
|
* @version $Revision$ $Date$ |
|
49 |
*/ |
*/ |
50 |
class StreamInputStream extends DTPInputStream |
class StreamInputStream |
51 |
|
extends DTPInputStream |
52 |
{ |
{ |
53 |
|
|
54 |
StreamInputStream (DTP dtp, InputStream in) |
StreamInputStream(DTP dtp, InputStream in) |
55 |
{ |
{ |
56 |
super (dtp, in); |
super(dtp, in); |
57 |
} |
} |
58 |
|
|
59 |
public int read () throws IOException |
public int read() |
60 |
{ |
throws IOException |
61 |
if (transferComplete) |
{ |
62 |
{ |
if (transferComplete) |
63 |
return -1; |
{ |
64 |
} |
return -1; |
65 |
int c = in.read (); |
} |
66 |
if (c == -1) |
int c = in.read(); |
67 |
{ |
if (c == -1) |
68 |
close (); |
{ |
69 |
} |
close(); |
70 |
return c; |
} |
71 |
} |
return c; |
72 |
|
} |
73 |
public int read (byte[] buf) throws IOException |
|
74 |
{ |
public int read(byte[] buf) |
75 |
return read (buf, 0, buf.length); |
throws IOException |
76 |
} |
{ |
77 |
|
return read(buf, 0, buf.length); |
78 |
public int read (byte[] buf, int off, int len) throws IOException |
} |
79 |
{ |
|
80 |
if (transferComplete) |
public int read(byte[] buf, int off, int len) |
81 |
{ |
throws IOException |
82 |
return -1; |
{ |
83 |
} |
if (transferComplete) |
84 |
int l = in.read (buf, off, len); |
{ |
85 |
if (l == -1) |
return -1; |
86 |
{ |
} |
87 |
close (); |
int l = in.read(buf, off, len); |
88 |
} |
if (l == -1) |
89 |
return l; |
{ |
90 |
} |
close(); |
91 |
|
} |
92 |
|
return l; |
93 |
|
} |
94 |
|
|
95 |
} |
} |
96 |
|
|