<code>
public
static
void writeRedis(String inpath, int[] keyIndex) throws Exception {
InputStream in =
new
URL(inpath).openStream();
LineIterator br = org.apache.commons.io.IOUtils.lineIterator(in,
"utf8"
);
JedisCluster cluster = RedisUtils.getClusterConn();
String[] line = null;
while
(br.hasNext()) {
String s = br.next();
line = RedisUtils.split(s);
String key =
""
;
for
(int i = 0; i < keyIndex.length; i++) {
key += line[keyIndex[i]];
}
cluster.setnx(key, s);
}
RedisUtils.clusterClose(cluster);
}`</code>