title: How do you read a text file but in a certain path java
body: <p>I have a read method which gets the key and a value from a text file so for example if I have:</p>
  
  <pre><code>Name: &lt;name&gt;
  </code></pre>
  
  <p>it would get the value</p>
  
  <p>The only thing in mind was using properties but I don't really know how to apply them for paths example:</p>
  
  <pre><code>Students:
  Name: &lt;Name&gt;
  </code></pre>
  
  <p>I want to get something like this <code>read("students.name");</code>
  and the output would be the name</p>
  
  <p>What I've done till now</p>
  
  <pre><code>public String read () {
      Properties properties = new Properties();
      try {
          properties.load(new FileInputStream(file.getPath()));
          for(String key : properties.stringPropertyNames()) {
              String value = properties.getProperty(key);
              return value;
          }
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>@TimBiegeleisen this is what I've tried right now maybe you could help me?</p>