I am trying to reform/reconstruct the string values from list. I am reading values from a text file. values in text file like below format.
H|013450107776|10/15/2019
D|TXN001|10/15/2019|013450107806|LCUATADA05|1000.00|PAYMENT FOR SERVICE|Successful
D|TXN002|10/15/2019|013458001581|LCUATADA04|1500.00|INVOICE 001|Successful
D|TXN003|10/15/2019|013450107784|LCUATADA01|1750.00|SEPT PAYMENT|Successful
H|007442500211|11/05/2019
D|1000000489|007442500211|0009204332|85585.44|SEPT PAYMENT|Successful
H|007442500213|11/05/2019
D|1000000489|007442500211|0009204332|85585.44|SEPT PAYMENT|Successful
D|1000000490|007442500211|0009204332|85585.44|SEPT PAYMENT|Successful
D|1000000491|007442500211|0009204332|85585.44|SEPT PAYMENT|Successful
find below code for reading file.
public Integer readFile(String fileName,String path){
List<String> lineList = new ArrayList<>();
try {
reader = new BufferedReader(new FileReader(
path+"/"+fileName));
String line = reader.readLine();
count =0;
while (line != null) {
lineList.add(line);
count ++;
line = reader.readLine();
}
reader.close();
} catch (IOException e) {
}
String packet=searchHeader(lineList);
try{
unmarshallResponsePacket(packet);
}catch(Exception e){
}
return count;
}
lineList contains values like
[ H|013450107776|10/15/2019,D|TXN001|10/15/2019|013450107806|LCUATADA05|1000.00|PAYMENT FOR SERVICE|Successful,D|TXN002|10/15/2019|013450107806|LCUATADA05|1000.00|PAYMENT FOR SERVICE|Successful,D|TXN002|10/15/2019|013458001581|LCUATADA04|1500.00|INVOICE 001|Successful, D|TXN003|10/15/2019|013450107784|LCUATADA01|1750.00|SEPT PAYMENT|Successful,H|007442500211|11/05/2019,D|1000000489|007442500211|0009204332|85585.44|SEPTPAYMENT|Successful...]
How i can form the string value(header information followed by detail
information) like
"H|013450207776|10/15/2019
D|0000TXN001|10/15/2019|013450107806|LCUATADA05|1000.00|PAYMENT FOR
SERVICE|Successful" from the List