喘JAVA糞?産喝謹?殻涙怦毘響函垓殻猟周 - 園殻秘壇利
喘JAVA糞?産喝謹?殻涙怦毘響函垓殻猟周扮寂:2011-09-09 blogjava funinhand厘峠扮曳熟浪散貫利貧油梧?嗤乂全俊和墮堀業湊蛸阻。泌惚喘 HttpURLConnection窃議圭隈嬉蝕銭俊?隼朔喘InputStream窃資誼補秘送?壅喘 BufferedInputStream更夛竃揮産喝曝議補秘送?泌惚利堀湊蛸議三?涙胎産喝 曝譜崔謹寄?油軟栖脅頁僅僅偬偬議?器音欺寔屎産喝議朕議。噐頁晦編園亟旗 鷹糞?喘産喝圭塀響函垓殻猟周?參和薮竃議旗鷹頁厘亟議MP3盾鷹匂議匯何蛍 。厘頁音奕担壘揖聞喘謹?殻和墮議?紗岻嗤議全俊和墮堀業云附祥曳熟酔?侭 參壓和墮堀業怎校議秤趨和?祥斑和墮?殻曜竃?岷欺峪複和匯倖和墮?殻。輝 隼?謹?殻嶄綜繁遊祐議棒迄諒籾、HttpURLConnection議階扮怦毘諒籾脅氏聞 旗鷹心軟栖呟械鹸墫。 酒勣初府匯和糞?謹?殻桟侘産喝議圭隈。繍産喝曝buf[]蛍葎16翠?耽翠 32K?和墮?殻減夭?産喝曝亟方象?耽肝亟匯翠?響?殻?BuffRandAcceURL窃 ?耽肝響弌噐32K議販吭忖准。揖化宙峰?亟/亟札鰍吉棋腎椀翠?亟/亟旺窟野 亟buf[]?響/亟旺窟聞喘buf[]。 将狛厘載海匯粁扮寂聞喘?厘範葎曳熟諾吭仇糞?阻厘議朕炎?揖凪万MP3殴 慧匂斤曳?厘議宸嶽圭隈嬬校曳熟送芥、糧協仇和墮旺殴慧。厘委糞?謹?殻和 墮産喝議圭隈亟竃栖?音怎岻侃尋萩答得峺屎。 匯、HttpReader窃孔嬬?HTTP亅咏貫峺協URL響函方象 /** *//** * author by http://www.bt285.cn http://www.5a520.cn */ package instream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; public final class HttpReader { public static final int MAX_RETRY = 10; private static long content_length; private URL url; private HttpURLConnection httpConnection; private InputStream in_stream; private long cur_pos; //喘噐畳協seek圭隈嶄 頁倦峇佩猟周協了 private int connect_timeout; private int read_timeout; public HttpReader(URL u) { this(u, 5000, 5000); } public HttpReader(URL u, int connect_timeout, int read_timeout) { this.connect_timeout = connect_timeout; this.read_timeout = read_timeout; url = u; if (content_length == 0) { int retry = 0; while (retry < HttpReader.MAX_RETRY) try { this.seek(0); content_length = httpConnection.getContentLength(); break; } catch (Exception e) { retry++; } } } public static long getContentLength() { return content_length; } public int read(byte[] b, int off, int len) throws IOException { int r = in_stream.read(b, off, len); cur_pos += r; |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |