62,567
社区成员




import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.Scanner;
public class URLReader
{
public static void main(String args[])
{
try
{
URL tirc = new URL("http://www.kkkmh.com/manhua/0609/mxo-mo-fa-xing-hui-mo-ai.html");
Scanner scan = new Scanner(tirc.openStream());
System.out.println(tirc.getHost());
while (scan.hasNext())
{
System.out.println(scan.next().replace("\\/", "/"));
}
}
catch (IOException e)
{
System.out.println(e);
}
}
public static String china(String args)
throws UnsupportedEncodingException
{
String s = null;
s = new String(args.getBytes("UTF-8"), "Unicode");
return s;
}
}
/** */
/**
* 读取一个网页全部内容
*/
public String getOneHtml(String htmlurl) throws Exception {
URL url;
String temp;
StringBuffer sb = new StringBuffer();
url = new URL(htmlurl);
BufferedReader in = new BufferedReader(new InputStreamReader(url
.openStream(), "utf-8"));// 读取网页全部内容
while ((temp = in.readLine()) != null) {
sb.append(temp);
}
in.close();
return sb.toString();
}
Scanner scan = new Scanner(tirc.openStream(),"UTF-8")