Java Snippet Programming of String Object convert to Array

I have used an aggregated node that aggregates my columns into an array (double type).

I have then assigned it to a string variable (java.lang.string object) to another java snippet node for the next process.

However, I had difficulties to convert it back to an array (double type) so that i can process it in the java snippet node.

Can anyone give any idea? Help needed. Thanks in advanced.

- LM

I assume you used Arrays.toString(...) for the conversion to String. In this case -string is the converted String in this example-, you just have to

String sub = substring(1, string.length() - 1);
String[] parts = sub.split(",\\s*");

Double[] ds = new Double[parts.length];
//Sorry, no option yet to use Streams
for (int i = 0; i < parts.length; i++) {
   try {
     ds[i] = Double.parseDouble(parts[i]);
   } catch (NumberFormatException e) {
      ds[i] = null;//not required
   }
}

(I have not tested, but most probably something like this might work.)

Got it! Thanks!