Need Help From Extension Developers

Can Anyone tell me how can I do this in java? :point_down: :point_down:

blocks

I don’t know about the java part, but for your info in kodular you can just use 1 block, instead of the loop to convert the list to csv (Comma-seperated value)

1 Like

After looking at some websites in Google, I have a few solutions without using dependencies.

Using StringBuilder

public String convertArrayToCsv(YailList list) {
    Object[] array = list.toArray();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < array.length; i++) {
        sb = sb.append(array[i]);
        if(i != array.length - 1) {
            sb.append(",");
        }
    }
    return sb.toString();
}

toString (not recommended)

public String convertArrayToCsv(YailList list) {
   String strList = list.toArray().toString();
 
   strList = strList.replace("[", "")
                 .replace("]", "")
                 .replace(" ", "");
   return strList;
}

This will replace all spaces including those in the original list value

You can actually use String.join(), however it is only available on java 8, which in extension you can use java 7 only.

2 Likes

This post was flagged by the community and is temporarily hidden.

6 Likes

yea I do not know java properly.

This post was flagged by the community and is temporarily hidden.

Ok, so again my posts are being flagged without any reason.
Whoever doing so, kindly pm me.

Yes, but what?

1 Like

i can try but i am not giving full confirmation as i am also a new coder i having only 1 year experience