To download a website source in Java you can use the following snippet.
Sample Java
private static String getUrlSource(String url) throws IOException { URL website = new URL(url); URLConnection connection = website.openConnection(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); String input; StringBuilder strBuilder = new StringBuilder(); while ((input = bufferedReader.readLine()) != null){ strBuilder.append(input); } bufferedReader.close(); return strBuilder.toString(); }
RT @CodeSnippetsNET: How to download a website source in #Java http://t.co/4nF1A66dY2 #programming #code #coding