String to int in Java
<p>I have a string named string1 that I read from a file. It's actually a number that I'm reading from the file. I now need to use that number in a random number generator. How can I do that?</p>

<pre><code>String string1 = in.readLine();
Random generator = new Random();
int x = generator.nextInt(string1);
</code></pre>

<p>That obviously fails but I can't figure out how to make it work.</p>
