Last active
August 5, 2022 21:23
-
-
Save junieldantas/7f4efd3df6c69efff6132ede42fa32d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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