To read a string from the keyboard, use the version of read Line( ) that is a member of the Buffered Spreader. Its general form is shown here: String read Line ( ) throws IO Exception As you can see, it returns a String object. The following program demonstrates Butterfingered and the read line ) method;’ the program reads and displays lines of text until you enter the word “stop”: The next example creates a tiny text .editor. It creates an airily of String objects and then reads in lines of text, storing each line in the array. It will read up to 100 lines or until you enter “stop”. It uses a Buffered Reader to read from the console
Here is a sample run:
Enter lines of text. Enter ‘stop’ to quit. This is line one. This is line two. Java makes working with strings easy’. Just create String objects.
stop Here This This Java Just is you file: is line’ one. is line two. makes Working create String with strings easy objects.