FileInputStream inherits from InputStream which has a mark() method which does nothing. FileInputStream itself doesn't define any mark() method. Even then, if I wrap a FileInputStream object inside a BufferedInputStream object and call markSupported() on it, it returns true. In the docs, it says that the mark() method of any FilterInputStream simply calls the mark() method of the underlying stream.
daudiam -6 Junior Poster
Recommended Answers
Jump to PostI don't know the answer, but I know where you can find it...
the entire source code of the API classes is freely downloadable from
http://download.java.net/jdk6/source/
so you can look at the code and see exactly how it is written.
Jump to PostYes which seems pretty logical given the context in which mark() and reset() methods are used i.e. the "going back" to a mark would be only supported if the underlying stream supports either random FP seeks(RandomAccessFile) or a buffered nature (BufferedInputStream).
Jump to PostBut then why do the docs say that calling markSupported() on an object of FilterInputStream's subclass (like BufferedInputStream) performs in.markSupported() where "in" is the underlying InputStream ?
Because that's what it is; calling mark/reset/markSupported on FilterInputStream *delegates* the call to the InputStream instance with which the FilterInputStream was created. This …
All 9 Replies
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
daudiam -6 Junior Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
daudiam -6 Junior Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
daudiam -6 Junior Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
daudiam -6 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.