我正在尝试将文件值与变量值匹配。但是它不匹配。我检查它正在读取文件并在变量中保存值,但不匹配。不确定是否必须使用contains函数。
int rcdMatch = 0;
String st;
String extdeductamt = "1000";
BufferedReader Br = null;
File objFile = new File(strPlanFile + NewFileNmae);
Br = new BufferedReader(new FileReader(objFile));
List < String > list = new ArrayList < String > ();
LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(objFile));
lineNumberReader.skip(Long.MAX_VALUE);
int lines = lineNumberReader.getLineNumber();
while ((st = Br.readLine()) != null) {
arraylist = st;
String amt = arraylist.substring(0, arraylist.length() - 392);
list.add(amt);
Set < String > unique = new HashSet < String > (list);
for (String key: unique) {
rcdMatch = 0;
if (key.trim().toString().equals(stvar)) {
String adjAmt = arraylist.substring(34, arraylist.length() - 348);
System.out.println("Adjustment Amount 1 is: " + adjAmt);
if (extdeductamt.trim().toString().equals(adjAmt.trim().toString())) {
rcdMatch++;
}
if (!(rcdMatch == 0)) {
System.out.println("PASS Amount is displayed: " + adjAmt);
}
}
break;
}
}