Taking input of a graph from text file in java till the end of file : <p>I have an input file which contains a weighted graph.</p>

<pre><code>a b 2
a c 8
a d 14
b f 19
b d 25
c d 21
d g 13
d f 17
e f 9
e g 1
f g 5
</code></pre>

<p>In each line first two inputs define nodes and third input defines the weight of edge between them.There is not specification in the beginning that how many nodes and how many edges I wish to take input.It will read till the end of file by itself.I want to read this file in java.Can anyone give me the solution for this?</p>
