PushbackInputStream - why exists -


Why is this good thing to push the byte back in the stream? When I process the stream, I can ignore the byte or I can modify it, if I want to do this:

  try (InputStream = new FileInputStream ( "Test.txt")) {int aByte; Four c; While ((abyte = is.read ())! = -1) {c = (char) aByte; If (C == 'H') {c = 'X'; } System.out.print (c); }  

I examined Jawadox, but I still can not understand why and in some cases why should I return data in the stream. Pardon.

To push forward, push has to be pushed back with the option and some conditions are true or false. If the lie wants to move on to you as if you did not move forward, then you have to be told to push the stream in order to proceed. Otherwise you can change the moving part and continue from there. [View]

[or]

[or] book: "Complete reference part 2 by Herbert Slidd".

Pushback interstream is used when you parser data from inputstream, sometimes you have to read some bytes that are going to come, before you can see how you can interpret the current byte Are there. Pushback Intestream allows you to do this. Okay, in fact it allows you to push the bytes back into the stream. Next time you read, you will read these bytes again (). - Venkov -

  int c; While ((c = f.read ()) -1) {switch (c) {case '=': if ((c = f.read ()) == '=') {System.out.print ( ".eq."); } Else {System.out.print ("& lt; -"); F.unread (c); }}  

In this way you live in the flow of reading.

Caution: The side effect of making mark () or reset () methods in pushback instream is the inputstream used to make it. Use mark-support () to mark any stream that uses mark () / reset () /www.java-samples.com -


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -