`
bcworld
  • 浏览: 37944 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

CSDN表情批量下载

阅读更多

 

CSDN评论时有很多有趣的表情,可以通过程序将这些表情批量下载到本地

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

public class HttpConnection {

	public static void main(String[] args) throws Exception {
		
			new Thread(new Runnable() {
				@Override
				public void run() {
					try {
						URLConnection connection=null;
						OutputStream out=null;
						InputStream inStream=null;
						for (int i = 1; i <= 86; i++) {
							out=new FileOutputStream("E:/temp/"+i+".gif");
							connection= new URL("http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/"+i+".gif").openConnection();
							inStream= connection.getInputStream();
							byte [] buff=new byte[1024];
							int len=-1;
							while((len=inStream.read(buff))!=-1){
								out.write(buff,0,len);
							}
						}
						//循环结束,关闭流
						if (out!=null) {
							out.close();
						}
						if (inStream!=null) {
							inStream.close();
						}
						
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}).start();
		}
		

}

 

  • 大小: 43.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics