Hello guys, i have a problem, is there someone can help me?
this is my logic..
public static void Check_Fund(){
String header = "Text1,Text2,Text3,FUND_UALFND_1,FUND_UALPRC_1,FUND_UALFND_2,"
+"FUND_UALPRC_2,FUND_UALFND_3,FUND_UALPRC_3,FUND_UALFND_4,FUND_UALPRC_4,FUN D_UALFND_5,FUND_UALPRC_5,"
+"Text4,Text5,Text6,Text7";
String text = "ABC;CDE;EFG;PRMF;0;PRFF;50;PREF;;PRCF;0;PRMP;50;HIJK;;LMNO;PQRST";
String[] head;
String[] value;
String showText = "";
head = header.split(",");
value = text.split(";");
String regex = "\\d+";
String fund[] = new String[]{"PREF","PRMF","PRFF","PRCF","PRMP","PDFF","PSEF","PSCB","PSMF","PRGC","PRE P"};
List<String> list = Arrays.asList(fund);
for(int i = 0; i < value.length; i++){
for(String temp : list){
if(value[i].equals(temp)){
if(value[i+1].isEmpty() || value[i+1].equals("0")){
value[i] = "N";
value[i+1] = "000";
//head[i] = head[i].replace(head[i].substring(12, head[i].length()), "0");
//head[i+1] = head[i+1].replace(head[i+1].substring(12, head[i+1].length()), "0");
isi = value[i] + value[i+1];
}else if(value[i+1].matches(regex)){
if(value[i+1].length()==1){
value[i+1] = "00"+value[i+1];
}else if(value[i+1].length()==2){
value[i+1] = "0"+value[i+1];
}
isi = value[i] + value[i+1];
}
}
}
showText = showText + head[i] +":" + value[i] + System.lineSeparator();
}
System.out.println(showText);
}
And this is the OUTPUT
Text1:ABC
Text2:CDE
Text3:EFG
FUND_UALFND_1:N
FUND_UALPRC_1:000
FUND_UALFND_2:PRFF
FUND_UALPRC_2:050
FUND_UALFND_3:N
FUND_UALPRC_3:000
FUND_UALFND_4:N
FUND_UALPRC_4:000
FUND_UALFND_5:PRMP
FUND_UALPRC_5:050
Text4:HIJK
Text5:
Text6:LMNO
Text7:PQRST
How to make that OUTPUT LIKE THIS??
Text1:ABC
Text2:CDE
Text3:EFG
FUND_UALFND_1:PRFF
FUND_UALPRC_1:050
FUND_UALFND_2:PRMP
FUND_UALPRC_2:050
FUND_UALFND_3:N
FUND_UALPRC_3:000
FUND_UALFND_4:N
FUND_UALPRC_4:000
FUND_UALFND_5:N
FUND_UALPRC_5:000
Text4:HIJK
Text5:
Text6:LMNO
Text7:PQRST
Please help me..i am very stuck about this..