Skip to content

Instantly share code, notes, and snippets.

@junieldantas
Last active August 5, 2022 21:23
Show Gist options
  • Save junieldantas/7f4efd3df6c69efff6132ede42fa32d7 to your computer and use it in GitHub Desktop.
Save junieldantas/7f4efd3df6c69efff6132ede42fa32d7 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
class Utils {
public static void main(String[] args) {
var parametro = "35,00;123456;32,00;987654;15,89;654981";
var listas = listOfMaps(Collections.singletonList(parametro), ";");
System.out.println(listas);
}
static List<Map<String, String>> listOfMaps(List<String> list, String regex) {
List<Map<String, String>> x = new ArrayList<>();
var counter = new AtomicInteger(1);
list.stream()
.map(s -> s.split(regex))
.forEach(a -> {
for (int i = 0; i < a.length; i +=2) {
x.add(Collections.singletonMap(a[i], a[i + 1]));
}
});
return x;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment