A good answer might be:Five times. | |
Input LoopYou don't have to have five statements using readLine(); a loop can be used to execute it the required number of times. Here is a program that reads and echos the first five lines of a file:
Here is the program working with an input file: C:\users\default\JavaLessons>java MultiEcho < input.txt Enter line1: You typed: This is line one, Enter line2: You typed: this is line two, Enter line3: You typed: this is line three, Enter line4: You typed: this is line, uh... four, Enter line5: You typed: and this is the last line. D:\users\default\JavaLessons> | |
QUESTION 6:(Thought question: ) How would you send the output of this program to another file? Click Here after you have answered the question |