Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to create FileInputStream with mark feature?

Tags:

Is there any possible way to create FileInputStream with mark supported feature as true?

like image 574
Roshan Avatar asked Mar 31 '11 06:03

Roshan


People also ask

How do you use InputStream marks?

mark(int readlimit) method marks the current position in this input stream. A subsequent invocation to the reset() method reposition the stream to the recently marked position.

What is the difference between FileReader and FileInputStream?

FileInputStream is Byte Based, it can be used to read bytes. FileReader is Character Based, it can be used to read characters. FileInputStream is used for reading binary files. FileReader is used for reading text files in platform default encoding.

Does FileInputStream need to be closed?

Yes, you need to close the inputstream if you want your system resources released back. FileInputStream. close() is what you need.

What is Mark and reset in InputStream?

The mark() method of BufferedInputStream class in Java is used to mark the current position in the input stream. Reset() method of the same class BufferedInputStream is called after the mark() method. Reset() fixes the position at the last marked position so that same byte can be read again.


1 Answers

Wrap your Fileinputstream inside a BufferedInputStream.

The buffered streams support marks.

like image 89
Suraj Chandran Avatar answered Sep 23 '22 17:09

Suraj Chandran