Tyman23
2014-01-22 16:09:16 UTC
contains the text given in the first command line argument. If no command line argument is
given, it should print every line. I'm trying to figure out how to compare the user's input(search term) to stdin. What am I doing wrong?
import java.util.Scanner;
import java.lang.String;
public class LineFilter {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String newLine = keyboard.next();
if (keyboard == "") {
while (keyboard.hasNext()) {
System.out.println(System.in); }
} else {
while (keyboard.hasNext()) {
if (newLine.contains(System.in) {
System.out.println(keyboard.nextLine());
}
}
}
}
}