喘JAVA糞?産喝謹?殻涙怦毘響函垓殻猟周 - 園殻秘壇利
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-15
屈、IWriterCallBack俊笥孔嬬?糞?響/亟宥佚。 package instream; public interface IWriterCallBack { public boolean tryWriting(Writer w) throws InterruptedException; public void updateBuffer(int i, int len); public void updateWriterCount(); public void terminateWriters(); } 眉、Writer窃?和墮?殻?減夭?buf[]亟方象。 /** *//** * http://www.bt285.cn http://www.5a520.cn */ package instream; import java.io.IOException; import java.net.URL; public final class Writer implements Runnable { private static boolean isalive = true; private byte[] buf; private IWriterCallBack icb; protected int index; //buf[]坪"翠"沫哈催 protected long start_pos; //index斤哘議猟周了崔(? 斤噐猟周遍議陶卞楚) protected int await_count; //喘噐登僅:和墮堀業怎校祥 曜竃匯倖"亟"?殻 private HttpReader hr; public Writer(IWriterCallBack call_back, URL u, byte[] b, int i) { hr = new HttpReader(u); if(HttpReader.getContentLength() == 0) //糞箭晒 HttpReader斤?脅音撹孔 return; icb = call_back; buf = b; Thread t = new Thread(this,"dt_"+i); t.setPriority(Thread.NORM_PRIORITY + 1); t.start(); } public void run() { int write_bytes=0, write_pos=0, rema = 0, retry = 0; boolean cont = true; while (cont) { try { // 1.吉棋腎椀翠 if(retry == 0) { if (icb.tryWriting(this) == false) break; write_bytes = 0; rema = BuffRandAcceURL.UNIT_LENGTH; write_pos = index << BuffRandAcceURL.UNIT_LENGTH_BITS; } // 2.協了 hr.seek(start_pos); // 3.和墮"匯翠" int w; while (rema > 0 && isalive) { w = (rema < 2048) ? rema : 2048; //耽肝響叱K栽癖? if ((w = hr.read(buf, write_pos, w)) == -1) { cont = false; break; } |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于喘JAVA糞?産喝謹?殻涙怦毘響函垓殻猟周 - 園殻秘壇利的所有评论