Java tutorial
//package com.java2s; import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class Main { public static String getHttpText(String urlInfo, String userName, String password) throws MalformedURLException, IOException { URL url = null; String tempStr = null; url = new URL(urlInfo); HttpURLConnection huc = null; String credit = userName + ":" + password; String encoding = new sun.misc.BASE64Encoder().encode(credit.getBytes()); StringBuffer sb = new StringBuffer(); huc = (HttpURLConnection) url.openConnection(); huc.setAllowUserInteraction(false); huc.setRequestProperty("Authorization", "Basic " + encoding); BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream(), "utf-8")); String line = null; while ((line = br.readLine()) != null) { sb.append(line).append("\n"); } tempStr = sb.toString(); return tempStr; } }