forked from Datomic/datomic-java-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIO.java
More file actions
32 lines (26 loc) · 899 Bytes
/
IO.java
File metadata and controls
32 lines (26 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package datomic.samples;
import datomic.Connection;
import datomic.Util;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
public class IO {
public static void transactAll(Connection conn, Reader reader) {
List<List> txes = Util.readAll(reader);
for (java.util.Iterator<List> it = txes.iterator(); it.hasNext(); ) {
List tx = it.next();
conn.transact(tx);
}
}
public static URL resource(String name) {
return Thread.currentThread().getContextClassLoader().getResource(name);
}
public static void transactAllFromResource(Connection conn, String resource) throws IOException {
URL url = resource(resource);
transactAll(conn, new InputStreamReader(url.openStream()));
}
}