`
234390216
  • 浏览: 10243122 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
博客专栏
A5ee55b9-a463-3d09-9c78-0c0cf33198cd
Oracle基础
浏览量:463061
Ad26f909-6440-35a9-b4e9-9aea825bd38e
springMVC介绍
浏览量:1776384
Ce363057-ae4d-3ee1-bb46-e7b51a722a4b
Mybatis简介
浏览量:1399146
Bdeb91ad-cf8a-3fe9-942a-3710073b4000
Spring整合JMS
浏览量:395242
5cbbde67-7cd5-313c-95c2-4185389601e7
Ehcache简介
浏览量:680291
Cc1c0708-ccc2-3d20-ba47-d40e04440682
Cas简介
浏览量:531346
51592fc3-854c-34f4-9eff-cb82d993ab3a
Spring Securi...
浏览量:1185782
23e1c30e-ef8c-3702-aa3c-e83277ffca91
Spring基础知识
浏览量:469472
4af1c81c-eb9d-365f-b759-07685a32156e
Spring Aop介绍
浏览量:151591
2f926891-9e7a-3ce2-a074-3acb2aaf2584
JAXB简介
浏览量:68469
社区版块
存档分类
最新评论

java.net.URL的简单使用

    博客分类:
  • java
阅读更多
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class UseUrl {

	public static void main(String args[]) throws IOException {

		URL url = new URL("http://234390216.iteye.com/blog/1049256");
		URLConnection conn = url.openConnection();
		InputStream is = conn.getInputStream();
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		byte[] b = new byte[1024];
		int len = 0;
		while ((len = is.read(b)) != -1) {
			out.write(b, 0, len);
		}
		String result = out.toString("UTF-8");
		out.close();
		is.close();
		System.out.println(result);
	}

}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics