OK we are not done with the chapter on let's look at some of the important points we covered in this 2
chapter. 3
We began with looking at what streams are and we said streams are of two types byte streams uncocked 4
or streams to process character data like text classes that fall under characteristics are used and 5
the process non-current or Deda Lexa images crassest underbite streams audio's input stream an output 6
stream or abstract arsis that syllabus based classes for all byte oriented input and output streams 7
. 8
Similarly a reader and writer are abstract base classes for our characters and oriented input and output 9
streams. 10
And here is how you would read and write bytes or extremophile. 11
So this diagram captures everything for both bytes as well as text on the left. 12
You have a job program and on the right there is the fine. 13
If the file is something like an image then for reading we use a buffered input stream which would be 14
chained to a file input stream but could read text from a file instead of buffered input stream. 15
We use a buffer reader and we change it to an input stream reader which just don't change when file 16
input stream. 17
So for reading text we have one extra class which is the input stream reader which is a bitch bus that 18
is it acts as a bridge for converting bytes to characters not to write bytes to be a file. 19
We use a buffered output stream which will be changed when final output stream. 20
But to write characters to a file then instead of buffered output stream we use it buffered writer visually 21
bitching to an output stream later which is indention to file output stream recolored buffer classes 22
provide the benefit of buffering and this kind of chaining is an implementation of Decrypter design 23
Pakhtun. 24
One of the most common activities in Igle is to read books from fifes and here's how you would do it 25
. 26
Here we are using a cry with resources syntax and bedacht. 27
We do not need to have the finally block with the clean up or so it is much more cleaner try with resources 28
. 29
Take it off closing off those streams implicitly as we see here. 30
Always use a string builder when reading. 31
From fine. 32
Do not use a plus operator for concatenating which we know is a very expensive node that we use read 33
line method or buffer reader for reading a line of text from the underlying character stream. 34
And here is how you would read text entered by a user in the console. 35
Only difference here from reading from a file is that he had to be replaced. 36
File input stream system in recolor in the demo. 37
We also discussed how this can be done using the scanner class from Java dog Udal package scan and also 38
provide some additional convenient methods for reading primitives. 39
And here is how you would write extremophile you would use the right method off before writer. 40
In this case input the right method can be either a string or a character in it. 41
That is right as an ordered method. 42
And here is how we serialize NDC realized Java objects for serialising we use object output stream that 43
just change a buffered output stream which is and don't change a file that put string on to write an 44
object. 45
We make use of the write object method of object or string class. 46
Also the class of the object will be serialized. 47
Must implement Serializable interface and allies realize we simply use the corresponding input stream 48
process and we use the read object method of object input stream to read an object. 49
Important thing here is that we should read the objects in the same order in which they were serialized 50
. 51
Not that Beaufort's means here are used only for performance reasons. 52
So it is not required to use them. 53
And here are examples where serialization would be useful. 54
I think first one is probably the more typical use case serialization can be very helpful if you how 55
high traffic dynamic web pages that are not frequently updated. 56
That is how most frequent databases read operations. 57
Dan did Data bestride operations in such cases. 58
You can serialize Jawa objects to either disk or you can cache them using something like memcached and 59
serialized objects can also be transmitted across DBMS. 60
No you want your classes to wall not break because you don't know the process. 61
Then you can declare a constant Silverbush an ID and B have seen you going over Demel. 62
There are few cases where it Mistal break D.C. delegation. 63
So in general you need to be very careful when evolving Serializable causus new toy is one topic which 64
we don't discuss. 65
And that's because stree my way is most commonly used. 66
But I may also cover this topic sometime in the future. 67
It is mainly useful for High-Speed and especially when handling large files. 68
This is possible because no classes have tighter coupling with operating system on modeler. 69
They also permit you to use all Freep memory that is memory outside of them and that would be useful 70
as that area is not subjected to garbage collection on so there is no real estate. 71
I am moving on data during regular GC cycles. 72
Stream my work has also been re-implemented with and I will take it one day offspeed. 73
In fact input stream reader relies on and I will on for reading next line by line. 74
I think you would be better off using stream my role as it is also really fast. 75
Moreover if you are using a for this you would have to write some custom or so rigorously my work is 76
pretty fast too and in some cases where the files are not very large stream my work can be faster than 77
I will. 78
In general the recommendation is to actually benchmark for a particular situation to see which approach 79
is better but if fights are not very large. 80
I think you can go 4st my will also for reading next to line by line. 81
You can simply go get stream I will but when you're dealing with really large files then you might think 82
about unable. 83
So that's about it. 84
With the chapter on I hope you and you are learning about performing input and output. 85
Thank you