1

00:00:00,800  -->  00:00:07,650
In this and VIVIR see how we can process bite or the interface that is files containing non-terrestrial

2

00:00:07,650  -->  00:00:15,690
data like images that enable processing files is probably one of the most common activities we will

3

00:00:15,690  -->  00:00:18,980
also see how we can do this in an efficient way.

4

00:00:19,260  -->  00:00:24,960
And for that we will look at a picnic called buffering and in the process we will also look at a design

5

00:00:24,960  -->  00:00:27,480
pattern called decorator pattern.

6

00:00:27,540  -->  00:00:34,480
In fact decorator pattern is very heavily used within the I IO package at the end of the lesson.

7

00:00:34,520  -->  00:00:37,210
We will also do a shot them all of what we learned.

8

00:00:37,680  -->  00:00:39,600
It's just like building the lesson.

9

00:00:39,600  -->  00:00:45,480
But by the end of it they will have a solid understanding of how we can process byte oriented files

10

00:00:45,570  -->  00:00:48,050
efficiently.

11

00:00:48,060  -->  00:00:53,340
We already know that we can use file input stream for reading data from files.

12

00:00:53,340  -->  00:00:58,730
Similarly there is also a fine output stream for writing that or twice as we saw earlier.

13

00:00:58,770  -->  00:01:05,580
These classes extend input stream an output stream process since read and write metrics in input and

14

00:01:05,580  -->  00:01:07,650
output stream classes are abstract.

15

00:01:07,740  -->  00:01:12,450
These classes provide an implementation for those matters.

16

00:01:12,780  -->  00:01:16,330
We all need to look at how we can create a file input stream object.

17

00:01:16,440  -->  00:01:19,950
And here is how we can create a file output stream.

18

00:01:19,950  -->  00:01:23,500
The input parameter is simply the filename.

19

00:01:23,610  -->  00:01:29,780
There are a couple of other overloaded constrictors but this one I think is the most commonly used.

20

00:01:30,180  -->  00:01:37,440
Not that this constructor would create a new file if the file does not exist but a file does exist then

21

00:01:37,440  -->  00:01:42,990
it could simply override the fine but with file input stream a new file is not created.

22

00:01:43,020  -->  00:01:49,560
If it does not exist the constructor will simply throw the file off one exception and that makes sense

23

00:01:50,100  -->  00:01:54,380
as there is no point creating an empty file and read nothing from it.

24

00:01:55,430  -->  00:02:01,020
And here are some reasons for throwing a file not one exception plus one specific to file input stream

25

00:02:01,170  -->  00:02:03,000
and we just discussed it.

26

00:02:03,180  -->  00:02:05,930
Second one is specific to file output string.

27

00:02:06,060  -->  00:02:11,760
An exception will be generated if the file for some reason cannot be created for writing.

28

00:02:11,820  -->  00:02:16,770
Third and Fourth results apply to both file input as well as file output streams.

29

00:02:16,770  -->  00:02:21,870
Third is when the file is actually the directory first is when the file exists.

30

00:02:21,990  -->  00:02:27,550
But for some reason the file cannot be opened for reading or writing.

31

00:02:27,750  -->  00:02:33,840
We saw that the BBC could read what methods were used for reading or writing single backs even when

32

00:02:33,840  -->  00:02:38,470
we were using other variations of related matters where a byte array is used.

33

00:02:38,580  -->  00:02:45,510
They were internally still relying on the basic redirect matters but the problem is reading or writing

34

00:02:45,510  -->  00:02:53,700
single bytes in this way is way too expensive as each method invocation triggers or disk access.

35

00:02:54,030  -->  00:03:00,510
As an analogy it is similar to shopping without a car that is each item is carried separately to the

36

00:03:00,510  -->  00:03:01,870
checkout counter.

37

00:03:02,370  -->  00:03:09,780
So what we need here is a shopping cart and in programming terms that would correspond to something

38

00:03:09,780  -->  00:03:15,450
called buffering with buffering Eury the block of bytes into a memory buffer.

39

00:03:15,930  -->  00:03:21,750
And then you read from that memory buffer which is much more faster than reading from the disk.

40

00:03:21,750  -->  00:03:27,980
Similarly you would also write a block of bytes into the memory buffer and then flush all of the data

41

00:03:27,980  -->  00:03:28,070
.

42

00:03:28,080  -->  00:03:31,890
That is a once in a single operation.

43

00:03:31,980  -->  00:03:38,410
So once again we are not hitting the disk for each byte that we want to write and group offering.

44

00:03:38,430  -->  00:03:44,910
There are two specialized classes called buffer input stream and buffer output string and these classes

45

00:03:45,210  -->  00:03:52,110
are subclasses off filter input stream unfiltered Puchi which in turn subclass input stream an output

46

00:03:52,110  -->  00:04:00,510
stream process and a memory buffer that we are talking about is nothing but simple binary so both buffer

47

00:04:00,510  -->  00:04:08,340
input stream and buffer output stream have this binary and the default buffer sizes are 8000 bytes.

48

00:04:08,700  -->  00:04:15,310
But if needed we can set the buffer size to a different value by invoking one of the constructors.

49

00:04:16,320  -->  00:04:22,110
But the thing is buffered input and buffer output stream classes do not work independently.

50

00:04:22,380  -->  00:04:28,920
They work with other streams like file and put on file output streams that is buffered streams only

51

00:04:28,920  -->  00:04:35,280
provide buffering as the core functionality and do not take the responsibility of dealing directly with

52

00:04:35,280  -->  00:04:37,630
files on the disk.

53

00:04:38,240  -->  00:04:44,420
So to provide buffering a buffer stream will be chain are connected to another string.

54

00:04:44,550  -->  00:04:50,400
For example here a buffered input stream is chained to a file input stream which does the actual reading

55

00:04:50,400  -->  00:04:51,560
from the file.

56

00:04:52,140  -->  00:04:59,630
The blue Donard box you are can be visualized as the buffer on in terms of quote This is how it would

57

00:04:59,630  -->  00:05:00,710
look.

58

00:05:00,860  -->  00:05:05,950
The buffered input stream has a constructor which takes an input stream object as input.

59

00:05:06,410  -->  00:05:11,390
And that's how the two classes have changed since the input is an input stream.

60

00:05:11,390  -->  00:05:18,140
We can pass any input stream object but as we can specify an input stream object or any other instance

61

00:05:18,320  -->  00:05:21,350
of the subclass of input string class.

62

00:05:21,580  -->  00:05:26,930
Not that it's got to be a subclass of the input stream class as input stream class is abstract and we

63

00:05:26,940  -->  00:05:29,040
cannot instantiate it.

64

00:05:29,210  -->  00:05:33,370
No this kind of chaining is an example of a good object oriented design.

65

00:05:34,100  -->  00:05:40,230
As in sort of maintaining a single huge class we have several smaller classes with each class doing

66

00:05:40,250  -->  00:05:45,880
one thing and being able to extend the functionality of one class by changing it.

67

00:05:45,920  -->  00:05:52,370
And in that class for example here we are extending the functionality of filing stream class by creating

68

00:05:52,390  -->  00:05:55,780
that buffered input stream class.

69

00:05:56,160  -->  00:05:59,870
Not this design is nothing but decorator design pattern.

70

00:06:00,080  -->  00:06:06,170
He had buffered input stream is called as a decorator as it is create the file input stream object with

71

00:06:06,260  -->  00:06:08,510
additional buffer functionality.

72

00:06:08,750  -->  00:06:16,550
The decorator is also referred to as a proper class as it is dropping another object and a very important

73

00:06:16,550  -->  00:06:23,670
design principle called the Open Closed principle serves as motivation for decorator's bargain and according

74

00:06:23,660  -->  00:06:29,690
to this principle classes should be open for extension but glose for modification.

75

00:06:29,690  -->  00:06:31,630
And that is what is happening here.

76

00:06:31,920  -->  00:06:38,720
To add new functionality we are simply changing classes rather than modifying them does highlighting

77

00:06:38,720  -->  00:06:45,890
the possibility of introducing any new bugs but the question is how are these classes open for extension

78

00:06:46,880  -->  00:06:48,320
and for that to happen.

79

00:06:48,390  -->  00:06:55,580
Boot decorator as well as the object that is being decorated must have a common supertype.

80

00:06:55,580  -->  00:07:02,210
In our example both buffered input stream unfiled input stream input stream class as a common supertype

81

00:07:02,210  -->  00:07:03,410
.

82

00:07:03,410  -->  00:07:09,210
This way we can pass it on the Baho input stream object in place of a file input stream object and the

83

00:07:09,200  -->  00:07:16,130
read method can be in word as if it was word on the file input stream object and the matter of the buffer

84

00:07:16,130  -->  00:07:19,530
input stream object will give us the buffering benefit.

85

00:07:20,000  -->  00:07:25,730
Internally it accesses the read method of the file input stream object and will buffer the bytes read

86

00:07:27,640  -->  00:07:27,910
on.

87

00:07:27,920  -->  00:07:29,500
Here is the precise logic.

88

00:07:29,840  -->  00:07:35,690
So this is the read method in the buffer input stream class and it is basically an implementation of

89

00:07:35,690  -->  00:07:40,010
the abstract read method in the input stream class.

90

00:07:40,010  -->  00:07:45,160
So here is the buffer has some unread bytes than the first underbite is written.

91

00:07:45,770  -->  00:07:51,790
Otherwise it means that either the buffer is empty or all its bytes have already been read in either

92

00:07:51,870  -->  00:07:55,020
is willing to fill the buffer with fresh data.

93

00:07:55,460  -->  00:08:01,610
And for that the read method of the underlying stream is invoked not the underlying stream is simply

94

00:08:01,640  -->  00:08:05,940
a chain string that is fine input stream in Arties.

95

00:08:05,930  -->  00:08:11,960
So by having a common supertype variable to extend the functionality of the file input stream class

96

00:08:12,530  -->  00:08:16,000
by providing buffering as an additional capability.

97

00:08:16,140  -->  00:08:22,130
Also note that the method declaration here has the keyword synchronized which is a multi-threading feature

98

00:08:22,340  -->  00:08:25,100
that is used to add white data corruption.

99

00:08:25,320  -->  00:08:31,380
No because the matter is synchronized GBM has to ensure that only one thread is able to access the matter

100

00:08:31,550  -->  00:08:37,190
at any given point of time so some additional checks are performed when such kind of matters are in

101

00:08:37,200  -->  00:08:42,510
work thus causing slowness in execution speed and due to this.

102

00:08:42,750  -->  00:08:50,330
The second Bushnell of freedom can be booked their bikes are read in groups and here is a second version

103

00:08:50,340  -->  00:08:51,160
.

104

00:08:51,240  -->  00:08:56,760
Although this method is also synchronized since we are reading groups of bytes rather than single bytes

105

00:08:57,290  -->  00:09:00,020
there'll be fewer muttering locations.

106

00:09:00,050  -->  00:09:06,040
This method would read length number of bytes from the buffer into the input array starting at index

107

00:09:06,120  -->  00:09:11,500
position offset undeclared instant number of bytes read or minus one.

108

00:09:11,550  -->  00:09:13,980
If nostri Mr. minus one.

109

00:09:15,100  -->  00:09:17,740
Let's also look at how the matter is implemented.

110

00:09:18,290  -->  00:09:23,610
Most of the buffer has the requested amount of data then the data would be copied from the buffer into

111

00:09:23,610  -->  00:09:25,500
the input binary.

112

00:09:26,900  -->  00:09:33,170
But if the buffer does not have the entire data but has only partial data then the partial data is first

113

00:09:33,170  -->  00:09:40,030
copied into the input and next the buffer is filled by fetching data from the underlying stream.

114

00:09:40,040  -->  00:09:45,110
How does the read matter of the underlying stream is in work and the buffer itself is pozières input

115

00:09:45,120  -->  00:09:48,910
to the matter handler once the buffer is full.

116

00:09:49,110  -->  00:09:57,450
The remaining data is copied from the buffer into the input it know the Perkis is then the buffer does

117

00:09:57,450  -->  00:10:00,210
not have any They died on.

118

00:10:00,780  -->  00:10:07,590
And this gives If the buffer size is greater than the input array size then buffer is filled with fresh

119

00:10:07,620  -->  00:10:11,820
data unlearnt number of bytes is copied into the input area.

120

00:10:12,120  -->  00:10:18,810
But if that's not the case that is input array size is greater than or equal to the buffer size then

121

00:10:18,810  -->  00:10:21,940
the data is copied directly from the underlying stream.

122

00:10:21,970  -->  00:10:23,270
And today it.

123

00:10:23,940  -->  00:10:28,890
So data is not copied into the buffer as it would add no value.

124

00:10:28,890  -->  00:10:31,930
So he had that read method of the underlings I mean isn't good.

125

00:10:32,130  -->  00:10:34,540
The input byte Daria's argument.

126

00:10:35,130  -->  00:10:40,950
In fact in this case it doesn't make sense to use buffered input stream in the first place as in working

127

00:10:40,950  -->  00:10:45,320
code could have directly access the read method of the underlying stream.

128

00:10:45,780  -->  00:10:48,270
So it is just an extra word.

129

00:10:48,750  -->  00:10:50,430
So there's no internal logic.

130

00:10:50,640  -->  00:10:55,530
I would encourage you to look at the source code of this method just to get a feel of how this logic

131

00:10:55,530  -->  00:10:57,870
is actually implemented.

132

00:10:58,950  -->  00:10:59,760
Now here is the right.

133

00:10:59,760  -->  00:11:05,120
Matter of the buffered output stream and the correct input data to the buffer.

134

00:11:05,520  -->  00:11:12,510
But if buffer is full then data in the buffer is forced through us to the underlying string then the

135

00:11:12,510  -->  00:11:16,010
buffer is filled with the input data.

136

00:11:16,170  -->  00:11:18,840
And here is the second version of the right method.

137

00:11:18,880  -->  00:11:22,680
It simply writes the input or the contents into the buffer.

138

00:11:23,550  -->  00:11:29,580
If buffer does not have enough space then the buffer is face flushed and then the array contents are

139

00:11:29,580  -->  00:11:36,070
copied into the buffer not flushing the right method of the underlying stream is used.

140

00:11:36,270  -->  00:11:43,350
And we simply pass a buffer as the argument here count would be the index position of the last bite

141

00:11:43,360  -->  00:11:43,460
.

142

00:11:43,530  -->  00:11:51,150
That does not yet returned to the underlying stream but if input array size is greater than or equal

143

00:11:51,150  -->  00:11:56,680
to the buffer size then buffer is fast flossed unlike in the case of read.

144

00:11:56,830  -->  00:12:01,630
The recordings are written directly to the underlying stream.

145

00:12:01,620  -->  00:12:06,790
Notice how the right method of the underlying stream is in would get different arguments for both these

146

00:12:06,780  -->  00:12:08,040
actions.

147

00:12:08,700  -->  00:12:15,180
So in this case using buffer output stream is of no value unright method in the final output stream

148

00:12:15,300  -->  00:12:18,010
could have been invoked directly.

149

00:12:18,120  -->  00:12:24,210
So if you want to read or write some large amount of data in a single discusses in which case you don't

150

00:12:24,210  -->  00:12:30,480
need any buffering then you can directly access the read or white matter of the appropriate file stream

151

00:12:30,480  -->  00:12:34,290
class by passing the byte address in a book.

152

00:12:35,250  -->  00:12:40,290
But if you want to read data in smaller chunks which is generally the case then buffering is the way

153

00:12:40,280  -->  00:12:41,880
to go.

154

00:12:41,880  -->  00:12:43,750
So those are the right metrics.

155

00:12:43,800  -->  00:12:49,620
Also like read amateur's due to synchronization usually in web this version of the right method if you

156

00:12:49,620  -->  00:12:57,320
want better speed Novantrone method is involved on the decorator then it would internally invoke the

157

00:12:57,330  -->  00:13:04,520
clothes method of the underlying decorator stream not have the decorator is a buffer to put stream then

158

00:13:04,580  -->  00:13:09,960
invoke invoking close method would first flush all the bar contents and then close off the underlying

159

00:13:09,960  -->  00:13:11,500
stream isn't war.

160

00:13:11,860  -->  00:13:15,270
So for flushing internally Frush matter is used.

161

00:13:15,720  -->  00:13:21,140
But you don't have to invoke this method explicitly as both Boatright as well as disclosed method.

162

00:13:21,150  -->  00:13:24,550
Flush the buffer contents automatically.

163

00:13:24,960  -->  00:13:30,990
Also just note that there is nothing like closing a decorator's dream as it is simply a class providing

164

00:13:30,990  -->  00:13:33,050
some functionality like buffer.

165

00:13:33,610  -->  00:13:39,430
That is it is not really dealing with some physical device like in the case of a file stream.

166

00:13:39,570  -->  00:13:45,900
So decorator's simply invoke the close matter of the underlying string not the underlying stream is

167

00:13:45,900  -->  00:13:53,370
also articulator then it would Indonesia with the Close method on the object that it is decorating situating

168

00:13:53,380  -->  00:13:56,070
need not be restricted to just two classes.

169

00:13:56,190  -->  00:13:58,560
It can be more than two also.

170

00:13:58,560  -->  00:14:00,030
So that's about it.

171

00:14:00,100  -->  00:14:07,680
Just to summarize we use buffering technique to perform fast streets or faster writes internally a byte

172

00:14:07,820  -->  00:14:14,850
is used between the buffer data and the chaining process that we discuss is nothing but the decorator

173

00:14:14,860  -->  00:14:16,270
bargain.

174

00:14:16,410  -->  00:14:23,760
Now let's go ahead and do a very good bit more of what we just learned from for this demo.

175

00:14:23,860  -->  00:14:29,940
I have created a new package called com doc sematic square that I will and I have also created a new

176

00:14:29,940  -->  00:14:35,260
class within this package called I am all for this more we are going to test two things.

177

00:14:35,280  -->  00:14:38,020
One is file processing without using buffering.

178

00:14:38,050  -->  00:14:39,890
And for this we have this matter.

179

00:14:39,900  -->  00:14:42,930
And the second one is file processing with buffering.

180

00:14:42,990  -->  00:14:43,290
OK.

181

00:14:43,300  -->  00:14:46,010
And that's the second matter tested later.

182

00:14:46,020  -->  00:14:50,700
So the main thing is we are going to test both read and write operations and we're going to do a copy

183

00:14:50,700  -->  00:14:56,640
operation which means that we are going to read file a bite from a file and we're going to write those

184

00:14:56,640  -->  00:14:58,790
bytes to generate new file.

185

00:14:59,040  -->  00:15:00,670
OK so that's the copy operation.

186

00:15:00,660  -->  00:15:02,300
So let's just go ahead and look at that.

187

00:15:03,230  -->  00:15:04,190
Matter.

188

00:15:04,760  -->  00:15:10,650
So the input file name is what I learned or JPEG and output file name rather than hyphen or Rajib So

189

00:15:10,640  -->  00:15:12,750
it's a gyp quite honored set on fire.

190

00:15:13,760  -->  00:15:15,660
And here is the matter.

191

00:15:15,720  -->  00:15:20,580
Here we are creating an instance of this class called file and we are doing the act in order to get

192

00:15:20,580  -->  00:15:22,580
the size of the fight.

193

00:15:22,910  -->  00:15:24,670
But let's not worry about this file class.

194

00:15:24,690  -->  00:15:26,340
We will look at it later.

195

00:15:26,370  -->  00:15:29,070
So let's look at the read and write operations here.

196

00:15:29,070  -->  00:15:30,570
Here is a try catch block.

197

00:15:30,750  -->  00:15:36,310
So we are using the new try with resources syntax which has been introduced in Java 7.

198

00:15:36,410  -->  00:15:36,850
OK.

199

00:15:36,960  -->  00:15:42,930
And this does not require And finally block on here within the parenthesis we are creating an instance

200

00:15:42,930  -->  00:15:50,910
of the file input stream and input that constructor is the filename of the input file.

201

00:15:50,980  -->  00:15:56,770
And here we are creating an instance off file output stream and we are passing the output file in here

202

00:15:56,820  -->  00:15:57,180
.

203

00:15:57,430  -->  00:16:01,080
Onboard these explanations should be separated by a semicolon.

204

00:16:01,130  -->  00:16:03,010
Here you are measuring the start time.

205

00:16:03,090  -->  00:16:07,700
And here we are actually doing the in the while loop we are actually doing the both the read and write

206

00:16:07,710  -->  00:16:08,930
operation.

207

00:16:08,940  -->  00:16:12,520
So here in the parentheses we are reading the input file.

208

00:16:12,650  -->  00:16:16,450
Ok so we are invoking the read method on the file input string.

209

00:16:16,740  -->  00:16:19,540
So in this four input stream outhe's for output stream.

210

00:16:19,560  -->  00:16:24,460
So that's the normal the standard conventions which we use for these streams.

211

00:16:24,540  -->  00:16:29,390
So we are reading it under read motard we know it does a byte OK.

212

00:16:29,490  -->  00:16:31,320
Every location read answer byte.

213

00:16:31,500  -->  00:16:34,860
And if it reaches the end of the stream it returns a minus one.

214

00:16:34,860  -->  00:16:39,930
So as long as it does not it has a doctorate and minus one it means that it is able to read some bytes

215

00:16:40,560  -->  00:16:45,920
and the bytes read is stored in this variable called byte read which is of type.

216

00:16:46,290  -->  00:16:52,470
OK so now within the within the while loop the byte that has been read is being written into the output

217

00:16:52,470  -->  00:16:53,050
string.

218

00:16:53,100  -->  00:16:57,900
Ok so we are invoking the right method and we are passing the byte that has been read.

219

00:16:58,590  -->  00:17:02,880
And here you are getting the elapsed time and we are simply printing the elapsed time.

220

00:17:03,000  -->  00:17:05,880
So let's just go ahead and run this method.

221

00:17:07,020  -->  00:17:10,350
As you can see the file size is around 5 and B.

222

00:17:10,910  -->  00:17:14,790
So how are some of the video here.

223

00:17:14,850  -->  00:17:17,510
Because it doesn't take and I don't quantify seconds.

224

00:17:17,570  -->  00:17:24,150
So now let's go ahead and test the second one which uses buffering here and here is the matter.

225

00:17:24,780  -->  00:17:29,720
So within the try catch block this time we are using a buffered input stream and it has changed a bit

226

00:17:29,740  -->  00:17:29,810
.

227

00:17:29,830  -->  00:17:35,210
I need distrained with the file and put string on the file input stream has the input file name as a

228

00:17:35,220  -->  00:17:36,120
parameter.

229

00:17:36,270  -->  00:17:42,230
So the only addition here is we are changing with buffering put on buffered output streams can we are

230

00:17:42,240  -->  00:17:49,430
still using the private resource syntax and we're going to use the second versions of the both the read

231

00:17:49,430  -->  00:17:53,420
and write methods which read and write in groups of bytes.

232

00:17:53,520  -->  00:17:56,330
OK so we are we have to pass a byte array to them.

233

00:17:56,420  -->  00:18:02,130
OK I'm on the byte resizes photos and bytes and we know that the buffered input and output stream also

234

00:18:02,120  -->  00:18:07,770
use a local buffer local array but the before sites for that area is around 8 toes and bytes.

235

00:18:07,910  -->  00:18:09,790
So here we are using photos and bytes.

236

00:18:09,950  -->  00:18:15,560
So we will read into this Arri into this binary and we will just pass that binary to the right method

237

00:18:15,680  -->  00:18:18,160
in order to generate the output file.

238

00:18:18,780  -->  00:18:24,530
So here we are creating the local byte array and within the Y loop we are first invoking the read mattered

239

00:18:24,850  -->  00:18:26,590
and we are passing this byte array.

240

00:18:26,820  -->  00:18:29,130
So photos and bytes will be read into this array.

241

00:18:29,310  -->  00:18:35,760
And as long as as long as this method is not returning minus one we are going to execute the while matter

242

00:18:35,990  -->  00:18:38,370
and within the sorted with a widebody.

243

00:18:38,610  -->  00:18:44,490
And here we are invoking the right method on the output stream on the buffer output stream unbe are

244

00:18:44,490  -->  00:18:46,300
passing the Bible.

245

00:18:46,400  -->  00:18:52,620
So the contents of the Bible will be returned to the buffer output stream and we are though the offset

246

00:18:52,620  -->  00:18:57,960
here is zero and the number of bytes that we want to write as this one which has been read the number

247

00:18:57,950  -->  00:18:59,110
of bytes that has been read.

248

00:18:59,120  -->  00:19:01,850
So that is returned by the read method.

249

00:19:01,910  -->  00:19:02,760
So that's about it.

250

00:19:02,850  -->  00:19:06,160
And let's just run this.

251

00:19:06,810  -->  00:19:10,140
Now it's just taking 21 milliseconds you see.

252

00:19:10,220  -->  00:19:16,400
So that's the difference here because we are using buffered inputs buffer streams which has taken only

253

00:19:16,400  -->  00:19:23,300
21 milliseconds whereas for when we did not use the buffering technique it has taken around 25 seconds

254

00:19:23,320  -->  00:19:23,420
.

255

00:19:23,520  -->  00:19:24,200
OK.

256

00:19:24,200  -->  00:19:28,500
And within the buffer or within the buffering technique we are using the second version of the read

257

00:19:28,490  -->  00:19:33,660
and write matters because if we had we used only the read method it could how it would be a little bit

258

00:19:33,650  -->  00:19:38,780
cooler because all the read metrics on the right methods are synchronized.

259

00:19:38,970  -->  00:19:43,950
So we are reducing the number of matter in locations by reading and writing in groups.

260

00:19:43,940  -->  00:19:46,350
So we are using the second version of the Read matter.

261

00:19:46,700  -->  00:19:47,600
So that's about it.

262

00:19:47,660  -->  00:19:54,250
This new class is available in the resources section and you can just take a look at it and play around

263

00:19:54,260  -->  00:19:54,840
with it.

264

00:19:55,050  -->  00:19:55,500
Thank you.

265

00:19:55,490  -->  00:19:56,190
And happy courting
