]>
gcc.gnu.org Git - gcc.git/blob - libjava/java/io/InputStream.java
1 /* Copyright (C) 1998, 1999 Cygnus Solutions
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 * @author Warren Levy <warrenl@cygnus.com>
13 * @date October 2, 1998.
15 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
16 * "The Java Language Specification", ISBN 0-201-63451-1
17 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
18 * Status: Believed complete and correct.
21 public abstract class InputStream
27 public int available() throws IOException
32 public void close() throws IOException
37 public void mark(int readlimit
)
42 public boolean markSupported()
47 public abstract int read() throws IOException
;
49 public int read(byte[] b
) throws IOException
51 return read(b
, 0, b
.length
);
54 public int read(byte[] b
, int off
, int len
) throws IOException
56 if (off
< 0 || len
< 0 || off
+ len
> b
.length
)
57 throw new IndexOutOfBoundsException();
63 for (i
= 0; i
< len
; ++i
)
66 if ((ch
= read()) < 0)
67 return i
== 0 ?
-1 : i
; // EOF
68 b
[off
+ i
] = (byte) ch
;
70 catch (IOException ex
)
72 // Only reading the first byte should cause an IOException.
81 public void reset() throws IOException
83 throw new IOException("mark/reset not supported");
86 public long skip(long n
) throws IOException
88 // Throw away n bytes by reading them into a temp byte[].
89 // Limit the temp array to 2Kb so we don't grab too much memory.
90 final int buflen
= n
> 2048 ?
2048 : (int) n
;
91 byte[] tmpbuf
= new byte[buflen
];
96 int numread
= read(tmpbuf
, 0, n
> buflen ? buflen
: (int) n
);
This page took 0.039869 seconds and 5 git commands to generate.