How can I convert a double array of type String to a double array of type int ?
@PostMapping("/hole/coordinate")
@ResponseBody
public String saveCoordinate(@RequestBody Map<String, Object> params) {
System.out.println("params = " + params);
System.out.println("params = " + params.get("coordinate"));
return "success";
}
System.out.println(params.get("coordinate")); store
[[445, 292], [585, 331], [612, 223], [205, 532]]
There are m 2 elements of the double array.
ex) [a,b],[c,d].....m
At this time, I want to receive the result in the data type of int[][], not String.
I was wondering how can I convert from String to int[][].
I tried like below
int[] arr= Stream.of(str.replaceAll("[\\[\\]\\, ]", "").split("")).mapToInt(Integer::parseInt).toArray();
for (int i : arr) {
System.out.println("i = " + i);
}
but it give me
4
4
5
2
9
2
...
Best Regards!