
import redis.clients.jedis.Jedis;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Properties;
public static void main(String[] args) {
String fileName = "redis.properties";
Map<String,String> map = getProperties(fileName);
String host = map.get("host");
int port = Integer.valueOf( map.get("port") );
String auth = map.get("auth");
int select = Integer.valueOf( map.get("select") );
Jedis jedis = new Jedis(host, port);
String OK = jedis.set("name","罗小黑");
String name = jedis.get("name");
System.out.println("name=" + name);
private static Map<String,String> getProperties(String fileName){
Map<String,String> map = new HashMap<>();
Properties properties = new Properties();
InputStream inputStream = null;
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
properties.load(inputStream);
String host = properties.getProperty("host");
String port = properties.getProperty("port");
String auth = properties.getProperty("auth");
String select = properties.getProperty("select");
map.put("select",select);
System.out.println("read file:" + fileName + " fail");
} catch (IOException e) {

