1

00:00:00,890  -->  00:00:01,390
OK.

2

00:00:01,420  -->  00:00:06,010
Finally let's get back to our project and let's make some extensions.

3

00:00:06,060  -->  00:00:06,940
I think it's been a while.

4

00:00:07,020  -->  00:00:10,120
So it's time for us to extend our project.

5

00:00:10,530  -->  00:00:14,320
So we're going to get to some of the stuff we have learned in the previous lesson.

6

00:00:14,730  -->  00:00:20,190
And the main thing that we are going to test is how to read data from that text in an efficient way

7

00:00:20,190  -->  00:00:20,920
.

8

00:00:21,000  -->  00:00:22,950
So that's what we learned in the previous lesson.

9

00:00:22,950  -->  00:00:25,450
Now we are going to test that.

10

00:00:25,650  -->  00:00:33,060
Now if you recall we had this class data stores which was acting as a database and all the data was

11

00:00:33,060  -->  00:00:35,330
hardcoded here in this class.

12

00:00:35,370  -->  00:00:36,240
Ok here you are.

13

00:00:36,270  -->  00:00:37,260
Here we are.

14

00:00:37,650  -->  00:00:41,240
For example here we have the user data and we hardcoded it.

15

00:00:41,400  -->  00:00:44,150
And similarly if you go down we had babblings.

16

00:00:44,220  -->  00:00:46,790
And further down we had movies and books.

17

00:00:47,010  -->  00:00:49,040
So all of that it was hardcoded.

18

00:00:49,350  -->  00:00:51,120
So we were not using a database.

19

00:00:51,150  -->  00:00:55,290
So we had to rely on this class to provide that data.

20

00:00:55,290  -->  00:01:01,290
Now what we're going to do is we're going to move all of this data into files okaying or text files

21

00:01:01,340  -->  00:01:04,000
and we are going to read from that.

22

00:01:04,170  -->  00:01:07,290
So that's going to be a nice extension.

23

00:01:07,350  -->  00:01:08,710
So you're going to do that.

24

00:01:09,240  -->  00:01:16,080
And if you'll recall when we created this class we also created these four classes that text files that

25

00:01:16,080  -->  00:01:18,670
you'll see here book more we use it on babbling.

26

00:01:18,960  -->  00:01:21,250
They actually had that data with them.

27

00:01:21,360  -->  00:01:26,090
Of course we did not use any of those files but we just use the data from that.

28

00:01:26,370  -->  00:01:28,750
So but now we're going to use the files.

29

00:01:29,090  -->  00:01:29,360
OK.

30

00:01:29,370  -->  00:01:35,400
And the data that you'll see here is the data that we have here we simply copied the data and do these

31

00:01:35,400  -->  00:01:37,340
files and we just hardcoded them.

32

00:01:37,350  -->  00:01:41,670
So now we are going to remove all of this we are going to delete all of this and we are going to simply

33

00:01:41,760  -->  00:01:43,150
read from the file.

34

00:01:43,440  -->  00:01:45,160
So I wanted to read in the code.

35

00:01:45,210  -->  00:01:47,450
So you're not going to write any new code here.

36

00:01:47,550  -->  00:01:51,270
And in fact we have already seen the code and then the last lesson.

37

00:01:51,270  -->  00:01:54,980
So we are just going to review the code that has already been written.

38

00:01:54,990  -->  00:01:57,160
So it's it's the exact same code.

39

00:01:57,420  -->  00:01:59,740
So we don't have to write it again.

40

00:01:59,850  -->  00:02:02,800
So let's just go ahead and let's just look at the code.

41

00:02:03,450  -->  00:02:09,630
So if you recall this is the project really all I want is another project which is for our demo classes

42

00:02:09,690  -->  00:02:13,830
the classes that we use for demoing our concepts.

43

00:02:14,100  -->  00:02:16,430
So it really is a project that we created.

44

00:02:16,590  -->  00:02:23,400
And we had all these packages here and I have created a new package called as you can see this com semantic

45

00:02:23,400  -->  00:02:27,150
script through Leo and UKL and biton the utile class.

46

00:02:27,180  -->  00:02:31,790
I created this class called Sauti within the package I created this class called.

47

00:02:31,820  -->  00:02:32,980
I will you can.

48

00:02:33,210  -->  00:02:36,320
So you would how all utility classes.

49

00:02:36,450  -->  00:02:36,850
OK.

50

00:02:36,870  -->  00:02:41,040
Any utility classes that we are going to create will go into this package.

51

00:02:41,040  -->  00:02:43,730
So the first one that we have created is all your data.

52

00:02:43,860  -->  00:02:51,480
Ok I can hear how to read motard so that we can read data from these files undertreatment there has

53

00:02:51,480  -->  00:02:52,530
two parameters.

54

00:02:52,530  -->  00:02:54,400
One is data string array.

55

00:02:54,430  -->  00:02:55,770
Another is filename.

56

00:02:55,960  -->  00:03:02,640
OK so in a given invocation we would pass the final one off the filenames and we will read the data

57

00:03:02,760  -->  00:03:04,310
into this string at it.

58

00:03:04,320  -->  00:03:10,710
So it's kind of similar to the read method that we have seen in the reader class where we were passing

59

00:03:10,740  -->  00:03:11,990
a character characters.

60

00:03:12,380  -->  00:03:12,760
OK.

61

00:03:12,900  -->  00:03:14,990
So it's exactly identical to that.

62

00:03:15,000  -->  00:03:21,630
So in this case we would read for example for instance if we passed the user filename then we would

63

00:03:21,630  -->  00:03:26,320
use this data on each element in the idea would be filled up.

64

00:03:26,370  -->  00:03:30,580
One of the lines on these lines here that it is operated by DAPs.

65

00:03:30,630  -->  00:03:36,060
So in this case the array size would be fine by the time we read all of this the size of the string

66

00:03:36,060  -->  00:03:37,270
array would be fine.

67

00:03:37,860  -->  00:03:41,900
So each element in that it would store a single line.

68

00:03:42,120  -->  00:03:44,340
So here.

69

00:03:45,510  -->  00:03:51,570
So as we have as you can see here is a file name we are creating a file input stream object and we are

70

00:03:51,570  -->  00:03:57,030
chaining it to input stream reader or an input stream reader also has another parameter which is a character

71

00:03:57,030  -->  00:04:03,670
sort of it's just the encoding scheme and it is of 8 here and it is in Don't chained to a buffer treater

72

00:04:03,690  -->  00:04:05,280
for performance.

73

00:04:05,450  -->  00:04:06,180
OK.

74

00:04:06,210  -->  00:04:13,230
And this is the third try with the resources Sendak's that we are using here and here is a line and

75

00:04:13,650  -->  00:04:16,340
here we are reading invoking the read line method.

76

00:04:16,340  -->  00:04:23,700
We order did ask it and we are invoking it on the radar object on that line and we are storing that

77

00:04:23,700  -->  00:04:30,630
line in this Are called data and we are incrementing on the index variable as being incremented here

78

00:04:30,640  -->  00:04:30,710
.

79

00:04:30,780  -->  00:04:36,930
So it's initialized to zero and after adding in line it's once again being incremented on whenever we

80

00:04:36,930  -->  00:04:40,830
reach whenever read Landru dense and then we terminate dunno.

81

00:04:41,160  -->  00:04:44,270
It means that we have read everything that we need.

82

00:04:44,640  -->  00:04:48,960
Now here I just have to try I need to add some catch blocks here.

83

00:04:49,080  -->  00:04:51,000
So here is the first one.

84

00:04:51,270  -->  00:04:57,220
It says I need to add some exceptions here.

85

00:04:57,210  -->  00:04:58,180
The catch blocks here.

86

00:04:58,200  -->  00:05:03,970
So let's just go ahead and say I'd catch Glaus to try.

87

00:05:04,040  -->  00:05:08,880
So it's going to add to the cache but also on his unsupported and coding exception the other one is

88

00:05:08,880  -->  00:05:10,250
file not found exception.

89

00:05:10,280  -->  00:05:13,760
Another one is the last one is Iowa exception.

90

00:05:14,250  -->  00:05:19,200
Now we don't have those errors anymore here.

91

00:05:19,770  -->  00:05:22,330
But first let me run this existing file.

92

00:05:22,340  -->  00:05:23,730
So that's the old version.

93

00:05:23,780  -->  00:05:26,070
So far everything is running fine.

94

00:05:26,070  -->  00:05:29,610
So now it's time to commandeers out

95

00:05:33,060  -->  00:05:36,030
and here it is.

96

00:05:36,390  -->  00:05:39,460
So this is a new chord.

97

00:05:41,220  -->  00:05:47,580
So this is a little user's method and that they just are class so it's going to load user data.

98

00:05:47,970  -->  00:05:53,700
So here we are creating a string instance and we have a total of five users.

99

00:05:53,700  -->  00:06:00,240
So the size of the string arrays 5 and we are invoking the I will you tell Metford the read method and

100

00:06:00,240  -->  00:06:08,430
we are passing this data the string array and we are passing the name of the file which is user.

101

00:06:09,690  -->  00:06:13,050
OK so user has all of this data here.

102

00:06:13,050  -->  00:06:14,440
So this is the ID field.

103

00:06:14,460  -->  00:06:15,800
This is the.

104

00:06:15,990  -->  00:06:21,300
And third one I need to see what that is but this is the first name last name.

105

00:06:21,300  -->  00:06:24,340
This is the gender under the user type I guess.

106

00:06:24,360  -->  00:06:24,580
Yeah.

107

00:06:24,610  -->  00:06:26,760
And this is the password.

108

00:06:26,880  -->  00:06:28,140
So that's the thing.

109

00:06:28,280  -->  00:06:31,870
And here we are reading the reader once the data is read.

110

00:06:32,340  -->  00:06:39,180
We are the next step is to just do whatever we are doing here which is to create user instances and

111

00:06:39,180  -->  00:06:39,810
store them.

112

00:06:39,810  -->  00:06:42,160
And this they called us users.

113

00:06:42,340  -->  00:06:43,050
OK.

114

00:06:43,290  -->  00:06:44,840
So that's what we are doing here.

115

00:06:44,850  -->  00:06:50,300
In each iteration we are creating a single user instance on storing it in the users.

116

00:06:50,310  -->  00:06:50,870
Ari.

117

00:06:50,930  -->  00:06:51,500
OK.

118

00:06:51,720  -->  00:06:55,270
So here we are iterating the string array.

119

00:06:55,740  -->  00:07:02,130
And in each iteration we are going to read a single line that has been read and since it is tabular

120

00:07:02,130  -->  00:07:03,680
McGirt we are splitting that line.

121

00:07:03,690  -->  00:07:05,110
We are we are calling it as a roll.

122

00:07:05,130  -->  00:07:12,150
Each line this is being called as a row and we are splitting it by TAB delimiter but tab delimiter because

123

00:07:12,300  -->  00:07:17,250
the data is delimited by tabs and so the values get stored here.

124

00:07:17,520  -->  00:07:22,530
And then the sixth element is actually the gender.

125

00:07:22,590  -->  00:07:24,720
So we are getting that gender information here.

126

00:07:24,720  -->  00:07:30,750
So by default we are saying it is male but then if it happens to be F in which case we are reassigning

127

00:07:30,750  -->  00:07:33,240
it to wit and gendered or female.

128

00:07:33,390  -->  00:07:38,310
Otherwise we are re-assigning a good transgender and everything is fine here.

129

00:07:38,400  -->  00:07:39,170
It's a long way.

130

00:07:39,300  -->  00:07:41,310
The first one the idea is long.

131

00:07:41,310  -->  00:07:47,970
So we are doing a long Darbar so long to get along well you and everything else is fine.

132

00:07:47,970  -->  00:07:53,040
So let's just go ahead and run with this first change and everything is fine.

133

00:07:53,100  -->  00:07:57,970
So let's go ahead and make the second change also.

134

00:07:58,610  -->  00:08:03,810
And this is for ramblings.

135

00:08:07,710  -->  00:08:09,470
So here is the blank file.

136

00:08:09,570  -->  00:08:15,450
And you have this information here and you can ignore the last fill here for all of the bookmarks wabbling

137

00:08:15,450  -->  00:08:16,180
movie and book.

138

00:08:16,200  -->  00:08:21,030
There is this thing called the unknown which is which indicates the kid friendly starters but you don't

139

00:08:21,030  -->  00:08:22,800
have to worry about it for now.

140

00:08:23,060  -->  00:08:24,000
So

141

00:08:26,740  -->  00:08:34,830
OK so similarly we are declaring the string here creating the string array and this value is five count

142

00:08:35,040  -->  00:08:35,820
per type.

143

00:08:35,820  -->  00:08:39,070
So we are going to have five bookmarks for each type.

144

00:08:39,100  -->  00:08:43,630
So let's start variable and we are passing this name weblink.

145

00:08:43,980  -->  00:08:44,940
And the same thing.

146

00:08:44,940  -->  00:08:48,710
We are simply spreading the values and we are invoking it here.

147

00:08:48,710  -->  00:08:53,880
Our only thing is the unknown value which you read which I said that we can ignore as being ignored

148

00:08:53,880  -->  00:08:55,130
here.

149

00:08:56,010  -->  00:08:58,570
And the same bet movies do.

150

00:08:58,590  -->  00:09:04,450
So let me comment this out.

151

00:09:08,090  -->  00:09:08,520
OK.

152

00:09:08,520  -->  00:09:13,340
So we are passing the movie as a filename here and we are spreading the values.

153

00:09:13,420  -->  00:09:16,620
Only thing is cast here and diverters.

154

00:09:16,710  -->  00:09:22,800
So if you go here cast and directors can have multiple values which are supported by commas.

155

00:09:23,100  -->  00:09:25,460
So this piece of code is taking care of that.

156

00:09:25,470  -->  00:09:28,680
So we are splitting that into String Array here.

157

00:09:29,310  -->  00:09:34,740
And we are simply passing those values here.

158

00:09:34,760  -->  00:09:39,240
Gaston directors are being passed us a string Arrius.

159

00:09:39,480  -->  00:09:45,550
So that's what movies and the final bonus books.

160

00:09:46,230  -->  00:09:52,320
So I'm going to upload these three methods three or four methods into a file so you can look at data

161

00:09:52,350  -->  00:09:55,060
in the resources section.

162

00:09:55,170  -->  00:09:58,610
So here you are passing book and bookmark count.

163

00:09:58,620  -->  00:10:05,210
Once again file eins here only the authors can have multiple values.

164

00:10:05,260  -->  00:10:07,900
So because a book can be written by multiple authors.

165

00:10:08,130  -->  00:10:14,190
So that's why we are using another split on the fifth the value that is supposed to represent the authors

166

00:10:14,190  -->  00:10:14,610
.

167

00:10:14,640  -->  00:10:15,650
So that's about it.

168

00:10:15,750  -->  00:10:20,500
So we have all of this sort of mirrored around it one more time and everything is running fine.

169

00:10:20,520  -->  00:10:22,740
It's well-tested so it's running fine.

170

00:10:22,740  -->  00:10:27,850
So I'm going to just upload those methods.

171

00:10:27,870  -->  00:10:33,840
This matter I don't have to upload I think you can write it yourself but I might also upload this.

172

00:10:33,870  -->  00:10:40,430
So that's about it that's how we are going to read data here by chaining multiple training so that's

173

00:10:40,440  -->  00:10:46,600
the recreative Madden Huynh buffer reader helps in reading it in a very efficient way.

174

00:10:46,890  -->  00:10:48,850
And we are using UTF 8 here.

175

00:10:48,990  -->  00:10:50,280
That's about it.

176

00:10:50,650  -->  00:10:51,480
And thank you
