KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > unimi > dsi > fastutil > io > MeasurableInputStream


1 package it.unimi.dsi.fastutil.io;
2
3 /*
4  * fastutil: Fast & compact type-specific collections for Java
5  *
6  * Copyright (C) 2006 Sebastiano Vigna
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  */

23
24
25 import java.io.IOException JavaDoc;
26 import java.io.InputStream JavaDoc;
27
28 /** An {@link java.io.InputStream} that provides eager access to its length,
29  * and keeps track of the current position (e.g., the number of bytes read so far).
30  *
31  * <P>This class adds two methods, both specified as optional. This apparently bizarre
32  * behaviour is necessary because of wrapper classes which use reflection
33  * to support those methods (see, e.g., {@link FastBufferedInputStream}).
34  *
35  * @since 5.0.4
36  */

37
38 public abstract class MeasurableInputStream extends InputStream JavaDoc {
39     
40     /** Returns the overall length of this input stream (optional operation). In most cases, this will require the input
41      * stream to perform some extra action, possibly changing the state of the input stream itself (typically, reading
42      * all the bytes up to the end).
43      * Implementing classes should always document what state will the input stream be in
44      * after calling this method, and which kind of exception could be thrown.
45      */

46     public abstract long length() throws IOException JavaDoc;
47
48     /** Returns the current position in this input stream (optional operation).
49      *
50      * <p>Usually, the position is just the number of bytes read
51      * since the stream was opened, but in the case of a
52      * {@link it.unimi.dsi.fastutil.io.RepositionableStream} it
53      * represent the current position.
54      */

55     public abstract long position() throws IOException JavaDoc;
56 }
57
Popular Tags