首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

源控 demo

2012-12-21 
流控 demo??http://www.iteye.com/topic/190329看了下楼主的需求,感觉上面那位仁兄写的太麻烦了,写了一个

流控 demo

??http://www.iteye.com/topic/190329

看了下楼主的需求,感觉上面那位仁兄写的太麻烦了,写了一个方法,你看下如何 public static byte[] read(int speed,InputStream fin) throws IOException{ byte[] b = new byte[speed]; ByteArrayOutputStream out = new ByteArrayOutputStream(); int len = 0; while(fin.available() >0){ len = fin.read(b); out.write(b,0,len); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } return out.toByteArray(); } 

热点排行