使用Java语言将数据读取再写入redis数据库中存储
public class Demo07 {
public static void main(String[] args) throws Exception{
Jedis jedis = new Jedis("master", 6379);
BufferedReader br = new BufferedReader(
new FileReader("D:\\Program Files\\IDEA\\IdeaProject\\shujiabigdata\\data\\student.txt"));
String line;
while ((line=br.readLine())!=null){
String[] split = line.split(",");
String id = split[0];
String name = split[1];
String age = split[2];
String sex = split[3];
String clazz = split[4];
HashMap<String, String> map = new HashMap<>();
map.put("id",id);
map.put("name",name);
map.put("age",age);
map.put("sex",sex);
map.put("clazz",clazz);
jedis.hmset("student:"+id,map);
}
br.close();
}
}