How can I read multiple line inputs? I want to create a program that will ask a user for a program code and it will count all the reserve words used in the program. Every time I copy and paste a code for the input, it only reads the first line. Help!
import java.util.*;
import java.lang.*;
import java.io.*;
public class Exer6
{
public static void main(String args[])
{
String[] dummy;
String[] reservew = {"abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "default", "do", "double", "else", "extends", "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while"};
String input;
int a=0, x=0, z=0, y=0;
int ReserveWords=0;
dummy = new String[1000000];
List rw = new ArrayList();
Collections.addAll(rw, reservew);
Scanner myObj = new Scanner(System.in);
System.out.println("Enter your program: ");
input=myObj.nextLine();
StringTokenizer inputF = new StringTokenizer(input, " \\/1234567890!@~$%^&*()_+:;|>.?<,[]{}-=`");
while(inputF.hasMoreTokens())
{
dummy[a]=inputF.nextToken();
if(rw.contains(dummy[a]))
ReserveWords++;
a++;
}
System.out.println("\n\nReserve Words: " + ReserveWords);
}
}