1
00:00:01,730 --> 00:00:02,360
Hi everyone.

2
00:00:02,360 --> 00:00:06,590
So in this lesson we will learn how to read from a file.

3
00:00:06,650 --> 00:00:09,480
So for example this is your file.

4
00:00:09,800 --> 00:00:13,840
My file not the 60 and let's say it is containing somebody down.

5
00:00:13,880 --> 00:00:21,180
So let's say this containing Hello World and then let's say it is containing integer 5.

6
00:00:21,440 --> 00:00:25,430
So this is the date that at this present in this fight my file not the 60.

7
00:00:25,490 --> 00:00:28,420
So for reading the detail from this fight again.

8
00:00:28,430 --> 00:00:33,410
So first of all we have to include the file so hash include file stream.

9
00:00:35,000 --> 00:00:37,240
So this is my domain.

10
00:00:37,250 --> 00:00:44,180
Now what I have to do so basically first of all we have to create the object of if stream class i.e.

11
00:00:44,400 --> 00:00:50,730
if a stream input file is stream class let's say the name of the object is in fine.

12
00:00:50,790 --> 00:00:54,140
We're digging can do so you will call the concept and you will give the file name.

13
00:00:54,180 --> 00:00:59,150
So my file not the 60.

14
00:00:59,170 --> 00:01:01,570
Now one important thing it is basically Liesel.

15
00:01:01,570 --> 00:01:03,380
This file my file not the 60.

16
00:01:03,670 --> 00:01:09,660
So this file must exist because it will not create a new file.

17
00:01:09,670 --> 00:01:13,930
Now there is one more way to open the file so first is during the constructor.

18
00:01:13,930 --> 00:01:16,690
Second is basically you create an object.

19
00:01:16,690 --> 00:01:23,590
So let's say if stream the object is in file two and there's a function open.

20
00:01:23,590 --> 00:01:24,820
So what you gonna do.

21
00:01:24,820 --> 00:01:31,150
You can call the function open so inviting to dot open and then you can give the name of the file the

22
00:01:31,150 --> 00:01:32,890
file that you want to open.

23
00:01:32,890 --> 00:01:38,620
So I want to open this file and the name is my filing not the 60.

24
00:01:38,650 --> 00:01:41,780
So there are two ways of opening the file first is using deconstruct.

25
00:01:41,920 --> 00:01:46,720
Second is basically using the open function simple now.

26
00:01:46,990 --> 00:01:50,470
So there might be a situation that my file does not exist.

27
00:01:50,470 --> 00:01:51,220
So what will happen.

28
00:01:51,220 --> 00:01:53,160
You can write if condition.

29
00:01:53,200 --> 00:01:53,800
So if

30
00:01:57,100 --> 00:02:01,300
in file do so if this file does not exist.

31
00:02:01,300 --> 00:02:03,600
So this condition will become true.

32
00:02:03,720 --> 00:02:08,620
You can do so you can write C out file does not exist.

33
00:02:12,960 --> 00:02:16,350
So this in file is actually a true false value.

34
00:02:16,410 --> 00:02:20,470
So if the file does not exist then you can print the file does not exist.

35
00:02:20,470 --> 00:02:22,090
So you can check also.

36
00:02:22,110 --> 00:02:25,530
Now there is one more function to check first is using this method.

37
00:02:25,530 --> 00:02:29,940
And second is basically you have a function is open so you can write it like this.

38
00:02:29,970 --> 00:02:30,300
If

39
00:02:34,440 --> 00:02:37,080
in file Dart is open.

40
00:02:37,080 --> 00:02:40,220
So this is a function is open it will return true.

41
00:02:40,320 --> 00:02:42,360
It will identical in value true or false.

42
00:02:42,390 --> 00:02:48,330
So if the file does not exist then you can write the same statement that file does not exist

43
00:02:51,590 --> 00:02:54,650
so you can use this way to check whether file exists or not.

44
00:02:54,650 --> 00:03:01,190
Or you can use this way to check whether my file exists or not Now what I want to do.

45
00:03:01,220 --> 00:03:04,090
So I want to read this file.

46
00:03:04,270 --> 00:03:05,230
So what is the format.

47
00:03:05,230 --> 00:03:08,470
So first of all you should know the format in which order the data is updating.

48
00:03:08,470 --> 00:03:09,810
So first is a string.

49
00:03:09,820 --> 00:03:11,380
Second is actually integer.

50
00:03:11,980 --> 00:03:13,410
So what do we do.

51
00:03:13,600 --> 00:03:14,700
First thing is a string.

52
00:03:14,710 --> 00:03:20,050
So you will create a variable string SDR for storing Hallowell and then you will create an in danger

53
00:03:20,080 --> 00:03:22,560
to store the digital value faith.

54
00:03:22,750 --> 00:03:23,010
Okay.

55
00:03:23,020 --> 00:03:28,930
So one important thing here is basically you should know the format the order in which the data is appearing

56
00:03:28,960 --> 00:03:31,570
in your text file.

57
00:03:31,660 --> 00:03:33,080
So what do you do.

58
00:03:33,220 --> 00:03:38,080
So you will use this object for example in file 2 I'm using in value or you can use in file.

59
00:03:38,110 --> 00:03:39,490
You can use any one of them.

60
00:03:39,940 --> 00:03:44,440
So for example if I'm using in file so I will write it like this in file

61
00:03:47,170 --> 00:03:47,750
SDR.

62
00:03:47,810 --> 00:03:54,200
Similarly in file I now after this what you can do.

63
00:03:54,200 --> 00:03:56,780
So after this you can print your data.

64
00:03:56,810 --> 00:04:00,460
So see out SDR and line.

65
00:04:00,470 --> 00:04:03,740
And similarly you can print your digital value which is five

66
00:04:08,580 --> 00:04:10,220
now after adding the compute data.

67
00:04:10,290 --> 00:04:11,700
I would reach and of the file.

68
00:04:11,730 --> 00:04:13,650
So this is end of file.

69
00:04:13,650 --> 00:04:18,090
Now I've a function and a file to check whether you reach an end of the file or not.

70
00:04:18,090 --> 00:04:20,080
So basically you can use this function.

71
00:04:20,130 --> 00:04:25,490
So if in file you will call this function.

72
00:04:25,520 --> 00:04:28,280
End of file E or F..

73
00:04:28,300 --> 00:04:32,860
Now this function will return true or a false value so this function will again a boolean value.

74
00:04:32,860 --> 00:04:37,260
So if it is returning true that means I have reached the end of the file so you can print a message

75
00:04:37,280 --> 00:04:45,090
like and a file reached now after doing all the work that you want to do with the file.

76
00:04:45,150 --> 00:04:48,360
The most important thing is basically you have to close the connection.

77
00:04:48,360 --> 00:04:50,720
So you have to call the function close.

78
00:04:51,030 --> 00:04:53,620
So I will call in file dot close.

79
00:04:53,640 --> 00:04:58,930
And similarly you can also call in file to dart close.

80
00:04:58,980 --> 00:05:01,920
So this is all about reading from a fine.

81
00:05:01,920 --> 00:05:04,100
Now one important thing here is basically.

82
00:05:04,170 --> 00:05:12,190
So there are two modes actually so you can use a us in and the second mode is basically us out.

83
00:05:13,190 --> 00:05:14,630
So us in mode.

84
00:05:14,630 --> 00:05:19,640
So this is actually for reading the data and I use out is actually for writing the data.

85
00:05:19,730 --> 00:05:21,530
So we call these flags.

86
00:05:21,530 --> 00:05:28,250
So these are called flags or you can call them modes but I am using input file stream so input files

87
00:05:28,250 --> 00:05:33,490
stream that means that automatically means that I want to use this when I want to basically read.

88
00:05:33,500 --> 00:05:36,590
So that's why you do not need to mention the flags.

89
00:05:36,630 --> 00:05:37,490
I'm repeating myself.

90
00:05:37,490 --> 00:05:41,740
There are actually two types of flag input and output.

91
00:05:41,750 --> 00:05:47,690
You want to read or you want to write but since I'm using input file stream then it is obvious that

92
00:05:47,720 --> 00:05:49,210
I want to perform the operation.

93
00:05:49,220 --> 00:05:53,260
So that's why you do not need to mention these flags any of these flags.

94
00:05:53,300 --> 00:05:58,780
So in the next trade deal we will write the code I will see on the next one but I.
