Java: Load data into variables from a .yaml file
<p>I've a Java program that should connect to two other machines (IP addresses and ports are known) and do a data comparison task.</p>

<p>Instead of hardcoding the IP and port in the Java source file, I created a <code>config.yaml</code> file and stored these there as follows, let's say this is the context of that file:</p>

<p><strong>config.yaml:</strong></p>

<pre><code>other machines:
  -"firstMachineAddress:162.242.195.82"
  -"secondMachineAddress:50.31.209.229"
  -"firstTargetPort:4041"
  -"secondTargetPort:4042"
</code></pre>

<p>Now I want to load these values in my Java source file and assign them to the variables I created already, such as:</p>

<p><strong>sampleClass.java:</strong></p>

<pre><code>// addresses of the machines which we will connect
    public final InetAddress firstMachineAddress = "";
    public final InetAddress secondMachineAddress = "";
    private final int firstTargetPort = "";
    private final int secondTargetPort = "";
</code></pre>

<p>I was wondering if Java provides a convenient way to achieve this?</p>