WEB开发网
开发学院手机开发Android 开发 如何成为Android开发高手 阅读

如何成为Android开发高手

 2010-08-31 00:43:00 来源:WEB开发网   
核心提示:082083http.setRequestProperty("Connection", "Keep-Alive");084085086087InputStream inStream = http.getInputStream();088089int max = 1024 * 10

082

083http.setRequestProperty("Connection", "Keep-Alive");

084

085

086

087InputStream inStream = http.getInputStream();

088

089int max = 1024 * 1024;

090

091byte[] buffer = new byte[max];

092

093int offset = 0;

094

095print("线程 " + this.threadId + "从位置"+ this.startPos+ "开始下载 ");

096

097while (downLength < block && (offset = inStream.read(buffer, 0, max)) != -1) {

098

099saveFile.write(buffer, 0, offset);

100

101downLength += offset;

102

103downloader.update(this.threadId, block * (threadId - 1) + downLength);

104

105downloader.saveLogFile();

106

107downloader.append(offset);

108

109int spare = block-downLength;//求剩下的字节数

110

111if(spare < max) max = (int) spare;

112

113}

114

115saveFile.close();

116

117inStream.close();

118

119print("线程 " + this.threadId + "完成下载 ");

120

121this.finish = true;

122

123this.interrupt();

124

125} catch (Exception e) {

126

127this.downLength = -1;

128

129print("线程"+ this.threadId+ ":"+ e);

130

131}

132

133}

134

135}

136

137private static void print(String msg){

138

139Log.i(TAG, msg);

140

141}

142

143/**

144

145 * 下载是否完成

146

147 * @return

148

149 */

150

151public boolean isFinish() {

上一页  15 16 17 18 19 20 21 22 23 24 25  下一页

Tags:如何 成为 Android

编辑录入:coldstar [复制链接] [打 印]
赞助商链接