INPUT-OUTPUT FUNCTIONS (BufferedReader CLASS) - JAVA PROGRAMMING

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to our channel so in the previous session we have seen one one way to read the input from the keyboard as a runtime in java programming that is by using scanner tests and in this session let's have a look on the second method that is bufferedreader see so here this bufferedreader we can read input from either keyboard or by using fine likewise we need a file with a some some data and from the de file we can directly access the data by using this buffer trader see this buffered reader is used to read the characters reach the characters from the input string from the character input string right so as we know there are three input strings I was strings that is system volume system garroted system dot yeah right so come to this system in so here we can read a byte by byte information by using the system dot in so here there is an one more class to read all the bytes and to decode it into the characters so before applying this bufferedreader the inputstreamreader class will read the bytes and it will decode it into the some character set so this is one more class in freedom so it will read bites and decoded to character set so from this character sick we can use this buffer greater right so this is done with the help of the input state system brought in this is done by wind software with the help of system dot image is the standard I was string and there is a one more class to read the data from the file that is final dinner so just go through the convention naming conventions we have discussed that every class name should start with a capital letter at every second board in the class name also should start with the capital letter so here it is a capital letter finally to the second I mean new steam unit is a gas and a file is also a class so in the class the first word input I capital steel second word just capital reader third word are capital he also Feige of capital are our capital similarly there is a one more time so suffice reader it is used to read the data from funds right so this is user to read the data from files so this is the first step we have to do and all these bytes which I have taken from this system protein or sub files will be before word that means a collection of information will be buffered and through this buffer we will use this buffer reader to read the data so this is the buffer then the data is same so all the data all the information of the input future which is taken from the system noting as well as from files I thing will be buffered and by using this buffer trader we can access the data from this buffer so buffered rated class so here also buffer triggers is a cancel in the buffer rated the first word buffered be capital and grade and our character some of you understood this is the fastest step we have to do and this is the second step we have to do so in order to read an input by using this buffered reader first we have to read the bytes from the keyboard or from the files and it should be converted into a character set so by means of these two classes inputstreamreader and the violator and once all the data is buffered we can use this buffer Raider class to access the data from the buffer so we can access this buffer by using an object right so in the previous session we have said any class cannot invoke their methods so a class cannot be broke the methods so in order to invoke the methods or access the methods we have to create an instance of the class that we call it as an object so first we have to create an object then through the object we have to access the methods so let us see one by one what is the syntax so once again say inputstreamreader gasps this is usual to read the bytes from the system for standard input and fire needle is used to read the bytes of information from existing files so here there is a question of if you if you are accessing if you are accessing the data from the file which does not exist right so if you are accessing the data from the file which doesn't exist then it will raise an exception so here always we have to include an IO exception while implementing this bufferedreader class so by using this buffer trader we can read input from keyboard and file so if it is a file so if the if we are accessing the data from the file which does not exist one exception will be raised so we have to throw an exception while using this before trader so that exception is called I exception so here I will eat all the three are capital letters I will exception input-output exception so this exception will be error in reading the input or printing the output so hope you understand so this bufferedreader class is available in I will package are you package so if you are implementing this bufferedreader we have to import import Java dot IO dot star or simply because very Java dot IO dot input stream later I would go further so both the packages we have to input so I am going to statements we can write it in a single statement that input Java dot IO dot star so whatever the class is available in I will all the classes can be accessed in our program so all these classes will be available in I will package C so this is the first step and this is the second step let us take it now let us see what are the methods available in bufferedreader right so buffered reader will read only the characters reach characters of strings or systems so except the characters and strings it will not read any input so a I mean integers or floats so before using the integer value we have to read the character and then we have to type convert that into an integer C so what is the methods so method and read and read line so two meters I will be in the before header class to read the input what is the red line so read it single character it means single character and if we want to read multiple characters then we have to use this red line it rings multiple characters simply we can save as a string so Liang is used to read a string so how to implement this radial gradient so by using the object and before using them we have to typecast the string to integer so for typecasting we had a method called passing percent right and in order to implement this percent we have to lose with the class integer integer dot parseint of this particle method similarly float dot pass float so as I said this is a method the first character always will be a small smaller lowercase character and the first letter of this next come next word will be the capital so parsing I capital password F character and I order to implement this method we have to access this method by using this calf name so fruits don't pass flow passing in detail dot parse it and here we have to access this rate of rate LED methods so we write a program so that you can understand right so in order to read the data by using this buffer theta will let us use the system protein then we can use in the fights ok system routine so for this first we have to access or read the data by using the inputs chain reader so input stream reader write some I are here is an object I are is equal to the new keyword input stream reader from the kyboot social system not in so this is the syntax to read the bytes and convert into the character set by means of this I R so input stream reader ayah is equal to new in boosting reader system cottony so from the keyboard the bytes will be covered it into characters and it will be accessible to ir object now in the second step we have to read the character set data from the buffer so that can be done by using prefer greater so buffered reader pass space some beer so this is an object name and as i said that the object names can be anything so it's a programmer machine so billion is equal to new bufferedreader so from where we have to read the data from this object I I so here I am from the keyboard the data is given desire and from the ayah by using this beer method I am will be an object we are accessing the data let it be integer if you want to read an integer so in J is equal to so by default it will be the character so we have to typecast so far the typecasting we have to use an integer class dot parse int off we have to access the method which method read over again so that method is available before winner and bufferedreader class cannot directly access the methods of raid or pregnant so in order to access the lead or replay methods which are the can be done only by this method created for this class so bufferedreader class having the better like an object beer so by using this beer we have to access the rear door again so here we can write be a dot read line so here we give same method so R is a small letter and L is a capital letter in order to read a fault fruit B is equal to fruits not pass floats again we can write we have not read line so a single method can read everything because here we can read only the characters or strings and it should be converted into integer or a float when it is in white and in order to read a string simply we can write string STR is equal to directly we can read we are not really so here there is no type conversion because by default it will treat the stain that the input is will be in a string right so this is a simple thing to read the input from keyboard by using this I was team right now let us see the second method that is reading the data from fine so here also the same thing so everything is same but the only thing is in order instead of using this input stream later we have to use a file later C in order to delete this this one from files we can write fine reader some fr is equal to new file reader it's a cache in a constructor and here we have to give the location right so it'll be my program is in some detail right right some in Java right in Java and there is a file name has input dot txt and I have to write the concrete location of this file complete location of this file so then we will write it D corn slash here the single slash will not be access so if you want to implement the slash we have to use the double slash they call a double slash Java again double slash versa finally input input dot txt so include this location in double quotes and closer this location in the whole course and the semicolon also must be there right so in the first step from the input or text that a bytes will be read by using this F farm object and if you here we have to raise the data from F 1 F 1 right so here also we can read only the data in it character set so we can directly read some string STR is equal to BR dot readline right so this will read the text from this file input dot txt file and it will be assigned to the string so that way we can print some system dot out dot println our brain STR so this will directly print the data which is available in this input dot txt to the screen so this is the one more method to read the data from files by using this bufferedreader class so hope you understood this buffer cache so by using this buffer reader class we can read the data from the keyboard as well as from the finest so if you are using the data I mean if you want to read the data from the keyboard we have to use the input stream reader class and if you are reading the data from the files they how to reuse the final render text right so let us write a program so once again if this file is not available if this file input file is not available in that location it will raise an exception so we have to write the exception also so let us write a small program has some buffer so inside the class how to write the main function so public static void main string arts here we have to throw an exception so I go exception I will exception monk we can write input stream reader some IR is equal to glue input stream reader system dot in and off from the ayah we have to read the data will receive the preferred render class bufferedreader vr is equal to Nu buffer later for this I am tortured from the I object now freedom in a is equal to class name dot passing of BR dot lady Thiang similar fee sting yes captain remember that stay STR is equal to some DL dot simply we can bring system dot out dot println similarly system dot out dot println this dear so then close the main function and the class so this is a simple program to read the data from the keyboard and break that from the string right so hope you understood this one let us stop here the next session we will see the command-line arguments how to implement this command-line arguments in java programming so if you really understood my sessions like my sessions and if you are having any doubts regarding this programming and particularly in this I will put statements or functions feel free to post your thoughts in the comment section so that I will definitely try to clarify all your doubts and share my sessions with your friends and don't forget to subscribe to our Channel thanks for listening thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 72,427
Rating: undefined out of 5
Keywords: sundeep, saradhi, kanthety, java programming, java basics, java fundamentals, beginners, programming fundamentals, java introduction, object oriented, oops, oop concepts, abstraction, inheritance, polymorphism, encapsulation, java compiler, platform independent, portable, javac, class file, scanner class, nextint, nextfloat, nextdouble, print, println, printf, system class, iostream, util, io package, inputstream, outputstream, BUFFEREDREADER, INPUTSTREAMREADER, FILE READER, BYTES, CHARACTER SET
Id: ufdChySSFc0
Channel Id: undefined
Length: 21min 18sec (1278 seconds)
Published: Mon Dec 24 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.