读书人

源控 demo

发布时间: 2012-12-21 12:03:50 作者: rapoo

流控 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(); } 

读书人网 >编程

热点推荐