package demo11;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;import java.util.Scanner;import org.apache.commons.io.IOUtils;public class ScannerTest { @SuppressWarnings("resource") public static void main(String[] args) throws MalformedURLException, IOException { String s = new Scanner(new URL("http://www.cewan.la").openStream(),"UTF-8").useDelimiter("\\A").next(); System.out.println(s);//方法一 String s2 = IOUtils.toString(new URL("http://www.cewan.la").openStream(),"UTF-8"); System.out.println(s2);//方法二 }}