Java生成html静态网页

    public static void makeHtml() {
        try {
            URL url = new URL("http://www.baidu.com/");
//本实事例通过读取百度页面来生成静态页面,你要是想把自己程序里面要生成的jsp页面转化成静态页面,则可以在url构造器的参数中的参数写上:如http://localhost:8081/NEW/new.do?cmd=list&sortId=2
            URLConnection conn = url.openConnection();//获得连接
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            BufferedWriter bw = new BufferedWriter(new FileWriter("D:/baidu.html"));
            String str = null;
            while ((str = br.readLine()) != null) {
                bw.write(str);
            }
            bw.close();
            br.close();
        } catch (MalformedURLException e) {
// TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
// TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


你可能感兴趣的:(java,localhost,网页,public,百度页面)