I have a csv file the format is like this:
I have a another csv file which is the same number of columns and rows.
I need to check if file 1 has same value (value[0]) as file 2 and if not copy value from file 2.
Below is the code I have written, but when checking, if file 1 first row value is not equal to the row, I need to go and check the next row of file 2 without exiting the if statement.
while ((line = br4.readLine()) != null){
while ((line5 = br5.readLine()) != null){
String[] values = line.split(",");
String[] values5 = line5.split(",");
fw5.append("0").append('\n');
String comp2 = values[0];
String comp1 = values5[0];
if (values5[0] == null ? values[0] == null : values5[0].equals(values[0]))
{
fw6.append(values[0]).append("mad men ").append('\n');
}
else if ( values5[0] == null ? (values[0]) != null : !values5[0].equals(values[0])){
System.out.println("value is " +values5[0]);
fw6.append(values5[0]).append("mad women").append('\n');
fw6.flush();
}
break;
}
}
You are facing a typical newbie problem: insufficient abstractions.
You try to solve your whole problem in one method: instead create helpful abstractions. Like this:
Long story short: slice your big problem into smaller ones and solve them one after the other.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.