2. Open a URL from java swing application or java standalone program coderanch.com |
3. please help me in how to create a java application to give url and get the requested page coderanch.comimport java.awt.Desktop; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; public class GiveUrlGetPage { public static String getPage(String url) { StringBuilder pageContent = new StringBuilder(); try { HttpURLConnection connection = (HttpURLConnection) (new URL(url)).openConnection(); BufferedReader pageReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line = ""; while ((line = pageReader.readLine()) != null) { pageContent.append(line); } } ... |