1

00:00:01,010  -->  00:00:08,280
Let's don't look at the file cross which is from the Djala doc either package it can be useful for manipulating

2

00:00:08,280  -->  00:00:14,970
files on the system that is you can use this class to do things like creating files creating directories

3

00:00:15,180  -->  00:00:19,530
deleting files and directories renaming files and so on.

4

00:00:19,650  -->  00:00:20,670
We will simply add more.

5

00:00:20,720  -->  00:00:25,380
Very we'll see some of the things that we can do with this class.

6

00:00:25,620  -->  00:00:32,040
We know that every file or directory on the disk has a certain unique but that is a part is used to

7

00:00:32,040  -->  00:00:39,720
locate the file on the directory and an instance of a file class would represent such a spot and it

8

00:00:39,720  -->  00:00:42,020
is instantiated as shown here.

9

00:00:42,660  -->  00:00:48,930
So telepresence a pop to a file order directory but not the contents of the file.

10

00:00:48,930  -->  00:00:54,450
Our first impression looking at this constructor would be that a file instance the presence contents

11

00:00:54,450  -->  00:00:58,250
of a file and that is not the case here.

12

00:00:58,260  -->  00:01:04,350
The string in the constructor is referred to as up happening not that the constructor does not throw

13

00:01:04,350  -->  00:01:10,130
an exception even if the pathname is invalid here Aalto just know that.

14

00:01:10,170  -->  00:01:16,860
But file input stream on file output stream classes have constructors which text file instance us an

15

00:01:16,860  -->  00:01:17,700
input.

16

00:01:18,270  -->  00:01:26,310
But I believe the constructors that we used which took filename as input are more commonly used on here

17

00:01:26,310  -->  00:01:32,770
are some really fundamental things which we need to know about the differences at the OS level.

18

00:01:32,780  -->  00:01:39,750
First is the directory separator in the pathname on Windows a backslash is used to separate the directories

19

00:01:39,750  -->  00:01:40,470
in the back.

20

00:01:40,480  -->  00:01:43,780
Name one on Unix forward slashes.

21

00:01:44,200  -->  00:01:49,560
There is also something called root directory which would be the first or the top most directly in the

22

00:01:49,560  -->  00:01:51,330
directory hierarchy.

23

00:01:51,480  -->  00:01:54,220
On Windows it would be drives like C and D.

24

00:01:54,600  -->  00:02:01,780
Well on Unix it would be represented by the forward slash on Unix if the bottom is G-I the slash em

25

00:02:02,390  -->  00:02:06,290
then the root would be the directory in which geode is present.

26

00:02:06,660  -->  00:02:11,580
So Geordi will not be the root but the directory in the G ID is present.

27

00:02:11,640  -->  00:02:14,610
That would be the root directory.

28

00:02:14,610  -->  00:02:20,860
Now as for the lines operators in a text file windows users garridge feet followed immediately by newline

29

00:02:20,980  -->  00:02:21,510
.

30

00:02:22,020  -->  00:02:27,120
On Unix it is just the new line coming to pathname.

31

00:02:27,150  -->  00:02:28,870
It can be either obsolete.

32

00:02:28,950  -->  00:02:35,910
Really do an absolute pathname points to the same location regardless of the current working directory

33

00:02:36,920  -->  00:02:42,300
and current What can that accrete which is also referred to as a user directory would be the directory

34

00:02:42,300  -->  00:02:46,210
in which you are Jola interpreter is running on my machine.

35

00:02:46,260  -->  00:02:50,140
It would be geoduck slash Dymo in the C drive.

36

00:02:50,220  -->  00:02:56,820
You can also know that we are the user be our system property which is accessible from the get Propertius

37

00:02:56,820  -->  00:02:59,240
method of the system class.

38

00:02:59,360  -->  00:03:04,300
Now when it comes to relate to power them it is resolved with us but what wouldn't be accurate.

39

00:03:04,510  -->  00:03:07,280
So does it relate to the working directory.

40

00:03:07,500  -->  00:03:14,340
If it is not me or it should get clear in the demo and it is actually time for the demo one I'll sort

41

00:03:14,340  -->  00:03:17,530
of switch over to our editor.

42

00:03:18,030  -->  00:03:23,980
OK in this demo we're going to look at two new methods and here they are in the IRA demo glass.

43

00:03:24,030  -->  00:03:26,900
So let's just go ahead and look at the first matter.

44

00:03:27,510  -->  00:03:28,690
And here it is.

45

00:03:28,710  -->  00:03:35,340
So here we are first creating an instance of file and we are passing a file name which is valid and

46

00:03:35,330  -->  00:03:36,270
or jpeg.

47

00:03:36,270  -->  00:03:41,280
And here it is and are jpeg within the within that demo project.

48

00:03:41,310  -->  00:03:43,830
So it is within the demo folder.

49

00:03:44,340  -->  00:03:46,680
But here we also have this.

50

00:03:46,680  -->  00:03:49,200
So within the models as sarcy directory.

51

00:03:49,410  -->  00:03:51,930
And here we are using two dots.

52

00:03:52,170  -->  00:03:57,650
So we could have just had the filename as demos slash growled and Argiope.

53

00:03:58,030  -->  00:04:00,860
But I just wanted to show this notation here.

54

00:04:00,860  -->  00:04:05,450
Here are two dots indicates that it is referencing the parent directory.

55

00:04:05,680  -->  00:04:06,280
OK.

56

00:04:06,300  -->  00:04:09,590
Which means the directory in which sources present.

57

00:04:09,600  -->  00:04:16,210
OK so that we can do it this way or we can just remove this part on hybridize just valued and Arjay

58

00:04:16,220  -->  00:04:17,900
peg written Demel.

59

00:04:18,030  -->  00:04:19,820
And here we are using an extra slash.

60

00:04:19,950  -->  00:04:27,700
It's actually only one slash but ngalo we know that slash needs to be Skipwith and there's Slash.

61

00:04:28,200  -->  00:04:30,660
So to try we have boost lushest here.

62

00:04:31,030  -->  00:04:33,780
And so these are all the different methods.

63

00:04:33,780  -->  00:04:36,460
There are many methods within the file class.

64

00:04:36,630  -->  00:04:39,030
So we are also trying many of these methods.

65

00:04:39,300  -->  00:04:43,500
So let's just go ahead and actually run it and then we can look at each of the methods

66

00:04:46,350  -->  00:04:47,340
and here it is

67

00:04:50,500  -->  00:04:56,270
OK so the get absolute bat is giving us the absolute path off the file.

68

00:04:56,310  -->  00:05:04,220
Q So you can see the entire file including Pop name including SIRC under two dots.

69

00:05:04,510  -->  00:05:06,410
Now there is something called Get canonical bot.

70

00:05:06,440  -->  00:05:10,640
So that's another matter and it would actually read the simple pathname.

71

00:05:10,630  -->  00:05:12,890
So it's not going to include sarcy.

72

00:05:13,000  -->  00:05:15,030
And the two dots.

73

00:05:15,310  -->  00:05:18,320
And here we are trying to create a new file.

74

00:05:18,740  -->  00:05:24,980
And all of these methods as you can see are invoked on F which is the end of it is a variable that is

75

00:05:24,980  -->  00:05:27,250
referencing file instance.

76

00:05:27,280  -->  00:05:33,960
So but these do not get canonical path and create new file have to be inside the try catch block.

77

00:05:34,180  -->  00:05:36,750
Uncreate you'll find we're trying to create a new file.

78

00:05:36,940  -->  00:05:41,420
But in this case since the file is already there it read and save files.

79

00:05:41,810  -->  00:05:45,180
Then the next one is separate or so here it's actually a field.

80

00:05:45,190  -->  00:05:51,670
It's not a matter it's a field unseparated gives the the operator that separates the directory so it's

81

00:05:51,680  -->  00:05:54,640
a directory separator that will get in here.

82

00:05:54,760  -->  00:05:58,870
The operator operates their directories in the path name.

83

00:05:59,110  -->  00:06:03,630
So it is a backward slash since it's Windows system on separator.

84

00:06:03,660  -->  00:06:07,670
It is also another method which simply gives the same thing it gives the same thing but it returns a

85

00:06:07,660  -->  00:06:11,030
car where whereas operator returns this string.

86

00:06:11,020  -->  00:06:18,600
Now if you're let's say if you are creating some file on a particular machine and you want to clear

87

00:06:18,790  -->  00:06:25,460
this up in some kind of a directory in some directory then you it's better to use when you're creating

88

00:06:25,460  -->  00:06:26,900
the file name it's better to use.

89

00:06:26,990  -->  00:06:29,110
You'll make use of this separator field.

90

00:06:29,200  -->  00:06:29,960
OK.

91

00:06:29,990  -->  00:06:36,290
That way it will be specific to that directory to that machine on which the program is running.

92

00:06:36,560  -->  00:06:37,140
OK.

93

00:06:37,330  -->  00:06:39,370
So I just kind of like form independent.

94

00:06:39,380  -->  00:06:40,210
No.

95

00:06:40,270  -->  00:06:44,470
So instead of hard coding the separator you can make use of this.

96

00:06:44,620  -->  00:06:51,440
So that's not I in get parents integrated into the parent off the firewall and ogic bit under the tree

97

00:06:51,440  -->  00:06:51,760
.

98

00:06:51,820  -->  00:06:56,920
That would include the entire structure until wild and Argiope EC.

99

00:06:57,010  -->  00:07:03,470
OK excluding Reiland or depict in this case it's also retaining SIRC and double dots which would mean

100

00:07:03,470  -->  00:07:08,600
only this part the G ID under Obama and the next one is Last-Modified.

101

00:07:08,650  -->  00:07:16,300
So it does run the firewall's Last-Modified and it gives the time in milliseconds so milliseconds from

102

00:07:16,300  -->  00:07:17,780
1970.

103

00:07:17,920  -->  00:07:19,880
So that's qualis the epoch time.

104

00:07:20,000  -->  00:07:24,120
And so it would be the number of milliseconds since that particular time.

105

00:07:24,130  -->  00:07:30,040
Now if you use that milieu if this if this number if you if you convert it into ears it would be around

106

00:07:30,050  -->  00:07:31,250
46 years.

107

00:07:31,300  -->  00:07:36,340
You can actually try it in Google just search for milliseconds to ears and give this number and you

108

00:07:36,350  -->  00:07:37,230
should get it.

109

00:07:37,420  -->  00:07:41,460
Next one as whether the file exists yes whether the file is a file.

110

00:07:41,530  -->  00:07:44,820
Yes it's a file on the next one is whether it's a directory.

111

00:07:44,870  -->  00:07:45,650
No it's not.

112

00:07:45,670  -->  00:07:51,280
So it's false on the next one is the lend method which will read under size of the file which is around

113

00:07:51,280  -->  00:07:52,730
5 and B.

114

00:07:53,390  -->  00:07:58,270
Next I'm printing though my working directory the user directory.

115

00:07:58,270  -->  00:08:05,300
And as we mentioned we are going to in the get property matter with the system property user Aiyar and

116

00:08:05,830  -->  00:08:07,070
my directory is this one.

117

00:08:07,080  -->  00:08:09,260
Jerry strategem on next.

118

00:08:09,250  -->  00:08:11,520
We are trying to create some directories here.

119

00:08:11,890  -->  00:08:17,740
So first thing we are doing is we are creating a new file instance passing the new directory name and

120

00:08:17,750  -->  00:08:20,680
we are doing it in a relative path.

121

00:08:20,770  -->  00:08:21,040
OK.

122

00:08:21,040  -->  00:08:27,790
We are not using the absolute path which means that my current directory is a demo Jayati and Emel unbuttoned

123

00:08:27,790  -->  00:08:30,460
them all I want to create this directory.

124

00:08:30,700  -->  00:08:32,000
So undergirds set rules.

125

00:08:32,020  -->  00:08:35,840
So let me just refresh your head fly on them all.

126

00:08:36,250  -->  00:08:40,960
And as you can see that as directory has been created so are done so true here.

127

00:08:41,050  -->  00:08:43,130
So the method for that is and.

128

00:08:43,150  -->  00:08:45,280
BAIER make that accrete.

129

00:08:45,300  -->  00:08:49,630
And next we are creating one more directory within that directory.

130

00:08:49,660  -->  00:08:56,620
So if you go here you can also see that there is the best directory that God created.

131

00:08:56,620  -->  00:09:00,180
Next we are trying to delete that as a directory.

132

00:09:00,320  -->  00:09:02,230
And here it says false.

133

00:09:02,240  -->  00:09:06,920
It cannot do it because there is some content within the desk directory.

134

00:09:06,970  -->  00:09:12,250
If it is empty which means that there is no file or not directory only that it will succeed.

135

00:09:12,250  -->  00:09:13,970
It really is not true.

136

00:09:14,280  -->  00:09:19,540
Now in the next line we are trying to create multiple directories within test directory.

137

00:09:19,580  -->  00:09:23,990
So we are trying to create a directory called test run unbid within test run we are trying to create

138

00:09:24,010  -->  00:09:30,000
another directory called Test 2 and we are using the same method maybe undertreatment pretence of.

139

00:09:30,130  -->  00:09:31,310
So we cannot do that.

140

00:09:31,330  -->  00:09:38,200
Unflawed that we need to use this as the plural form off make a bit Acree and that would allow us to

141

00:09:38,330  -->  00:09:40,280
create that directories.

142

00:09:40,310  -->  00:09:40,960
But just one.

143

00:09:40,950  -->  00:09:41,540
Understood.

144

00:09:41,530  -->  00:09:45,250
So you need to use and keep the eye on this for that.

145

00:09:45,250  -->  00:09:46,240
So that's the thing.

146

00:09:46,390  -->  00:09:53,300
And next Finally here in this matter we are creating a new instance called Temp dot DXi and we are creating

147

00:09:53,310  -->  00:09:54,090
the new file.

148

00:09:54,160  -->  00:09:59,590
I notice that the file got signed should have been created.

149

00:09:59,620  -->  00:10:01,240
Maybe the child was already there.

150

00:10:01,270  -->  00:10:09,190
Yeah I think in my test runs the file was there so it got created and after that the next step is to

151

00:10:09,190  -->  00:10:16,180
rename that file name to a different name and in order to get the argument that this method is a new

152

00:10:16,180  -->  00:10:18,580
file Newfies instance with the new name.

153

00:10:18,820  -->  00:10:21,780
But in this sense it's just not the name.

154

00:10:21,790  -->  00:10:25,310
But we are also including a directory name here as did a tree.

155

00:10:25,330  -->  00:10:29,070
So what is going to happen is this is the name of the new file.

156

00:10:29,150  -->  00:10:35,320
And since the directory name is there this file time file temp.txt is actually moved into this directory

157

00:10:35,340  -->  00:10:35,510
.

158

00:10:35,690  -->  00:10:36,970
OK with this name.

159

00:10:37,000  -->  00:10:41,510
So if you go here and test directory you can see this file 1.60.

160

00:10:41,800  -->  00:10:43,470
So that's how you load more files.

161

00:10:43,480  -->  00:10:50,520
You can move files and you can also rename them and now let's look at the second matter which is Karlos

162

00:10:50,520  -->  00:10:51,950
did reflector.

163

00:10:51,970  -->  00:10:58,600
Now sometimes we want to look at the contents of a particular directory what files and directories that

164

00:10:58,590  -->  00:11:04,930
a particular directory has on the immediate files not a directory on the Internet within that directory

165

00:11:04,930  -->  00:11:05,220
.

166

00:11:05,350  -->  00:11:10,420
But our immediate three appearing directories on files appearing in a directory.

167

00:11:10,420  -->  00:11:15,610
Now if you want to do that if you want to see what what directories on file are appearing in a particular

168

00:11:15,610  -->  00:11:17,920
directory then you would use.

169

00:11:18,010  -->  00:11:22,810
And then we can use this method for that there is a method called us list.

170

00:11:22,810  -->  00:11:28,720
So here we are creating a file instance and it is referencing the current directory and the current

171

00:11:28,720  -->  00:11:31,650
directory would be the current working directory which is there.

172

00:11:31,940  -->  00:11:38,500
And within that directory We want to list all the directories and the files that are appearing immediately

173

00:11:38,500  -->  00:11:39,190
within that.

174

00:11:39,310  -->  00:11:44,680
And for that we use the list muttered Birgitta dense string theory which includes that it would include

175

00:11:44,710  -->  00:11:47,680
all the names of the directories on those files.

176

00:11:47,950  -->  00:11:53,420
So I'm passing this but I'm going to require a placeholder which is initially set to false.

177

00:11:53,560  -->  00:11:57,310
So if it is false it means that we want to list all of them here.

178

00:11:57,310  -->  00:11:58,120
Gayford is false.

179

00:11:58,120  -->  00:12:00,700
We are going to just invoke this method.

180

00:12:00,700  -->  00:12:07,420
So here you can see that there are all these different files and these are all files are in some directories

181

00:12:07,420  -->  00:12:10,580
here underground and Argiope quite also is here.

182

00:12:10,630  -->  00:12:20,200
Now if I wanted just if I passed through we are going into the last block on the block we are invoking

183

00:12:20,200  -->  00:12:24,700
a different version of the list method which takes a filtering criteria.

184

00:12:24,700  -->  00:12:31,350
Now sometimes we want to just look for files having certain extension for example.

185

00:12:31,510  -->  00:12:38,080
So in our case we want to just look for the epic files within the demo project and we want to ignore

186

00:12:38,080  -->  00:12:42,180
all the other directories on any other files like that the extreme.

187

00:12:42,190  -->  00:12:45,660
We just want to look for only the big files.

188

00:12:45,760  -->  00:12:48,230
So there is a certain filtering criteria.

189

00:12:48,490  -->  00:12:55,660
So the method argument here is an interface it's called as a filename filter it's an interface and using

190

00:12:55,660  -->  00:13:01,630
that interface if you can implement that interface and you can specify your criteria.

191

00:13:01,690  -->  00:13:03,910
And here it is at the bottom after that name.

192

00:13:03,970  -->  00:13:09,620
After this class I would add this new class called it a pre-filter be a filter I need implements to

193

00:13:09,620  -->  00:13:13,390
find them filter which has this method called accept.

194

00:13:13,510  -->  00:13:16,050
So in the Axert I have the filtering criteria.

195

00:13:16,090  -->  00:13:23,560
I'm saying that if the current file that is passed here it and spitted git big dodgy .jpg are the caps

196

00:13:23,650  -->  00:13:25,530
aren't gaps Dundon are true.

197

00:13:25,540  -->  00:13:27,370
Otherwise you would read enough files.

198

00:13:27,560  -->  00:13:29,470
Ok so.

199

00:13:30,100  -->  00:13:32,230
So let me pass this class.

200

00:13:32,230  -->  00:13:39,560
The instance of ductless to the list knotter the list method vote in lieu of the accept method with

201

00:13:39,640  -->  00:13:46,390
each file within the current current directory each file and the directory name.

202

00:13:46,420  -->  00:13:47,860
OK so it would pass.

203

00:13:47,860  -->  00:13:52,030
Each of them to the X up method in this that has been defined in this class.

204

00:13:52,030  -->  00:14:02,260
Now if I had to run this as you can see it is just printing only dog OPG and Dot end caps and ignoring

205

00:14:02,290  -->  00:14:05,050
everything else in that directory.

206

00:14:05,110  -->  00:14:08,500
So that's how you would look for 500 or Chris.

207

00:14:08,500  -->  00:14:13,690
In any given electorate immediately appearing files on directories.

208

00:14:13,690  -->  00:14:14,470
So that's about it.

209

00:14:14,470  -->  00:14:17,550
That's how you would manipulate files on the system.

210

00:14:17,590  -->  00:14:22,960
OK you can use them for creating directories deleting directories or renaming files.

211

00:14:23,110  -->  00:14:26,350
Looking at the fire sun looking at the file properties and so on.

212

00:14:26,440  -->  00:14:32,980
So go ahead and you can find the updated class and the resources section and you can play around with

213

00:14:32,980  -->  00:14:37,880
it and look at other kinds of matters that are there in the final class and that's about it.

214

00:14:38,020  -->  00:14:39,170
Thank you and happy coding
