public static long DownloadFile(String URLPath, String LocalFilePath) { assert (URLPath != null); assert (LocalFilePath != null); try { URL url = new URL(URLPath); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader(url.openStream())); BufferedWriter out = new BufferedWriter( new FileWriter( LocalFilePath )); String str; while ((str = in.readLine()) != null) out.write( str + "\n" ); connection.disconnect(); out.close(); in.close(); } catch (Exception a) { System.out.println( a.getMessage()); a.printStackTrace(); } return new File(LocalFilePath).length(); }