Java: mkdir by url source
<p>I want to make a Java downloader program, which will download the data from the url to some local default folder, such as /tmp/data.</p>

<p>However, if the url is like: www.site.com/book/1.html, I want to save the file 1.html into /tmp/data/book/1.html.</p>

<p>I don't know how to mkdir recursively, by which I mean make the "book" folder automatically.</p>

<p>The code I make the program to make file is like this:</p>

<pre><code>String dataDir = "/tmp/data";
URL url = new URL("http://www.site.com/book/1.html");
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(dataDir+url.getFile())));
bw.write(data.toString());
bw.close();
</code></pre>
