I am having trouble with the if statement even when the file explicit.txt only has the word abazure the program does not enter the if statement. The program just passes the if statement and outputs the word abazure again.
import java.util.Scanner;
import java.io.File;
import java.io.PrintWriter;
import java.io.FileNotFoundException;
public class Manzai {
public static void main(String[] args) {
String word;
Scanner input = null;
PrintWriter output = null;
try
{
input = new Scanner(new File("explicit.txt"));
output = new PrintWriter(new File("censored.txt"));
}
catch(FileNotFoundException e)
{
System.out.println("File explicit.txt was not found");
System.exit(0);
}
while(input.hasNext())
{
word = input.next();
if(word=="abazure")
{
word = "a******";
}
output.print(word + " ");
}
input.close();
output.close();
}
}