Below is my code, goal is to read instructions from a txt file to make java robot preform them. When changing any part of the if statement to != the robot portion works, therefore I have to think that the strings are in some way not equal.
public void interpretGoo() throws AWTException, FileNotFoundException,
InterruptedException{
Scanner scanner = new Scanner( new File("instruct.txt") );
String in;
String instruct = "";
while(scanner.hasNextLine()== true){
in = scanner.nextLine();
instruct+= in;
}
scanner.close();
String[] instructSet= instruct.split("-");
System.out.println("String: " + instruct);
String[] command= new String[10];
for(int i= 0; i< instructSet.length;i++){
command= instructSet[i].split(" ");
System.out.println("Set: " + instructSet[i]);
System.out.println("Word: " + command[0]);
if(command[0].trim()== "key"){
keyboardHandler(command[1].charAt(1));
Thread.sleep(150);
}else if(command[0].trim()== "clickL"){
accuMouse(Integer.parseInt(command[1]),Integer.parseInt(command[2]), 1, false);
}else if(command[0].trim()== "clickR"){
accuMouse(Integer.parseInt(command[1]),Integer.parseInt(command[2]), 0, true);
}else{
System.out.println("FAIL");
continue;
}
}
}
OUTPUT:
String: clickL 728 1062-clickL 540 382-key h-key e-key l-key l-key o-
Set: clickL 728 1062
Word: clickL
FAIL
Set: clickL 540 382
Word: clickL
FAIL
Set: key h
Word: key
FAIL
Set: key e
Word: key
FAIL
Set: key l
Word: key
FAIL
Set: key l
Word: key
FAIL
Set: key o
Word: key
FAIL
According to the output the strings are identical but fail the checks, any help would be appreciated!