Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch.claude_martin.playground;
- import java.io.IOException;
- import java.nio.charset.StandardCharsets;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.util.BitSet;
- import java.util.List;
- import java.util.stream.Collectors;
- public class SomeClass {
- public static void main(String[] args) throws IOException {
- String path = "matrix.txt";
- List<BitSet> matrix = Files.lines(Paths.get(path), StandardCharsets.US_ASCII).map(l -> parseLine(l))
- .collect(Collectors.toList());
- // ...
- }
- static BitSet parseLine(String line) {
- String[] a = line.split("\\s+");
- final BitSet bs = new BitSet(a.length);
- for (int i = 0; i < a.length; i++) {
- if (Integer.parseInt(a[i]) == 1)
- bs.set(i);
- }
- return bs;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement