Storing values in different variables by reading a file
<p>i'm a beginner at java and still learning so please excuse my question if it sounds stupid.</p>

<p>i've been stuck on a straight forward problem i was given:</p>

<p>i'm supposed to read a text file and store the values of the text file in different variables. my text file looks like:</p>

<p>foo.txt</p>

<pre><code>Directory_path=C:\University
school_name=SyracuseUni
</code></pre>

<p>i want to store the directory path and school_name in a new variable say</p>

<p>var_one = C:\University
and var_two = SyracuseUni</p>

<p>I was able to split it but in a single string.</p>

<pre><code>public static void main(String[] args) throws IOException {
        try {
            BufferedReader br = new BufferedReader(new FileReader("C:\\foo.txt"));
            String strLine = null;
            String var_one = null;
            String var_two = null;
            while ((strLine = br.readLine()) != null) {
                String[] parts = strLine.split("=");
                String parameter = parts[1];
                System.out.println(parameter);
            }
        }  
        catch (IOException e) {
            e.printStackTrace();
        }
    }
</code></pre>

<p>this gives me an output like this which isn't how i want it: </p>

<pre><code>C:\University
SyracuseUni
</code></pre>

<p>i will appreciate if anyone can guide me towards the right approach. thanks all.</p>