java - Read the first line in a stream and remove it from the stream -
I have 2 squares that should read a InputStream
, only the first line explanation Should do the stream but the first line should be removed from the stream so that everything can be understood after class B first line. When I pass my InputStream
with a BufferedReader
and readLine ()
I know that does not work I can read one on the stream unless I face a \ b, but maybe there is a more suitable solution to do the job?
// reads the first line from the stream and everything else rewrites the public stringFileNameTheFirstLineInInputStream (InputStream Inn) throws IOException {InputStreamReader isReader = new InputStreamReader (in); Buffer Reader = New buffed reader (header); Return Reader Readline (); }
You Remove to InputStream
, you can read from it, do not use BufferedReader
to read the line, because it's definitely InputStreamReader
(its To fill the buffer) will read a lot more than the first line, which reads from InputStream
.
I suggest reaching the end of the line using InputStreamReader
, then InputStream
example for your code that should be read by it.
BTW, you should always specify the encoding used by InputStreamReader
, otherwise the system encoding will be used to convert the bytes InputStream
May be different on different machines.
Comments
Post a Comment