I've got lines set up something like this:
A a-type_value
B b-type_value
C c-type_value
B b-type_value
C c-type_value
C c-type_value
A a-type_value
My Java code is reading lines like those from a file like so:
BufferedReader reader = new BufferedReader(new FileReader("C:\\Path\\to\\File.txt"));
try {
while (true) {
String line = reader.readLine();
if (line == null) break;
String[] fields = line.split("\t");
LineProcess(fields);
}
} finally {
reader.close();
The LineProcess() method looks like this:
public static void LineProcess(String[] input)
{
int result = 0;
String datetime = null;
System.out.println(input[0]);
if (input[0] == "A") {
result = Integer.parseInt(input[1]);
System.out.println(result);
}
if (input[0] == "B") {
bvalue = input[1] + input[2];
System.out.println(bvalue);
}
if (input[0] == "C") {
System.out.println(input[1]);
}
//System.out.println(input.length);
//for(int i = 0; i < input.length; i++)
// System.out.print(input[i] + " ");
//System.out.println("");
}
Although there are A's, B's, and C's in my input, the if statements are never catching them. I'm sure I'm making a simple mistake.
Thanks