public static void downloadResource(String filename, String urlString) throws FileNotFoundException, IOException
    {
    	BufferedInputStream in = null;
    	FileOutputStream fout = null;
            try
            {
                    
                    File f = new File(filename);
                    f.getParentFile().mkdirs();
                    if (f.exists())
                    {
                        return;
                    }
                    fout = new FileOutputStream(f);
                    in = new BufferedInputStream(new URL(urlString).openStream());
                    byte data[] = new byte[1024];
                    int count;
                    while ((count = in.read(data, 0, 1024)) != -1)
                    {
                            fout.write(data, 0, count);
                    }
            }
        catch (MalformedURLException ex) {
//            ex.printStackTrace();
        }            finally
            {
                    if (in != null)
                            in.close();
                    if (fout != null)
                            fout.close();
            }

    }