For Episode 53 of the Java Tutorial: https://youtu.be/_CAbm7Gma7Y
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
InputStreamReader ir = new InputStreamReader(System.in);//We make this object because BufferedReader requires it as a parameter
BufferedReader br = new BufferedReader(ir);//The object that will allow us to gather input
String strings[] = new String[100]; // Used to store all the lines of text. Can store up to 100 lines.
System.out.println("Type as many lines of text as you want. Press Enter for a new line.");
System.out.println("Type stop to stop. Your text will be stored.");
try{
for (int i = 0;i<100;i++){
strings[i] = br.readLine(); //Stores the lines of text into each index of the array
if (strings[i].equals("stop")){
break; //Ends the collection of input/loop when stop is typed
}
}
System.out.println("---------------------------------");
System.out.println("Here is all of your saved text: ");
//displays the up to 100 lines of text you typed
for (int i = 0; i<100; i++){ //Prints out each line until it comes up to the line saying stop
if (strings[i].equals("stop")){
break;
}
System.out.println(strings[i]);
}
}catch (IOException e){
System.out.println(e);
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
InputStreamReader ir = new InputStreamReader(System.in);//We make this object because BufferedReader requires it as a parameter
BufferedReader br = new BufferedReader(ir);//The object that will allow us to gather input
String stringy; //The variable we will use to store our strings read
System.out.println("Type as many lines of text as you want. Press Enter for a new line.");
System.out.println("Type stop to stop.");
try{
do{
stringy = br.readLine(); //stores the line of text into a string
System.out.println(stringy); //Prints out the string after reading it
}while(!stringy.equals("stop")); //The loop will keep running until the word stop is entered
}catch (IOException e){
System.out.println(e);
}
System.out.println("Done Gathering Input");
}
}