title: String hostname from properties file: Java
body: <p>This may sound like a really simple problem but I can't figure out a way around this. </p>
  
  <p>I have a config.properties file which contains two key values: an IP address and a Port number. I read this config file to extract the key values in string format. However, when I am trying to use these values, I am unable to connect to the IP address retrieved from the config file. </p>
  
  <p>The reason is that the values read are in string format and I need to convert them to proper formats before using them. What I want is that the value "192.168.1.40" stored in config file is converted to a <code>String host</code> format. I tried using InetAddress but that gives an error.
  The contents of the config file are:</p>
  
  <pre><code>IP=192.168.1.40
  PORT=9124
  </code></pre>
  
  <p>The code that uses these values is as follows:</p>
  
  <pre><code>Properties prop = new Properties();
  String propFileName = "...//testJedis//resources//config.properties";        
  prop.load(new FileInputStream(propFileName));//testJedis/resources/config.properties"));// configStream);
  
  Jedis jedis=new Jedis(prop.getProperty("IP"),Integer.parseInt(prop.getProperty("PORT")));
  //Jedis jedis = new Jedis("192.168.1.40",9124);
  </code></pre>
  
  <p>The error stack I obtain is as follows:</p>
  
  <pre><code>Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.UnknownHostException: "192.168.1.40"
  at redis.clients.jedis.Connection.connect(Connection.java:150)
  at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:71)
  at redis.clients.jedis.Connection.sendCommand(Connection.java:92)
  at redis.clients.jedis.BinaryClient.ping(BinaryClient.java:84)
  at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:65)
  at TestJedis.main(TestJedis.java:43)
  Caused by: java.net.UnknownHostException: "192.168.1.40"
  at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
  at java.net.PlainSocketImpl.connect(Unknown Source)
  at java.net.SocksSocketImpl.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at redis.clients.jedis.Connection.connect(Connection.java:144)
  ... 5 more
  </code></pre>
  
  <p>The documentation of jedis class can be found <a href="http://tool.oschina.net/uploads/apidocs/redis/clients/jedis/Jedis.html" rel="nofollow">here</a>! </p>
  
  <p>P.S.: If I directly pass the host address as string, it works properly (that means the host is perfectly reachable).</p>