public static void main(String[] args) { System.out.println(System.currentTimeMillis()); for (int i = 1; i < 2; i++) { int nRead = 0; String j = ""; if (i < 10) j = "00" + i; else if (i < 100) j = "0" + i; String sPath = sURL.replace("xxx", j); // String sName = sPath.substring(sURL.lastIndexOf("/") + 1, sPath.lastIndexOf("?")); try { URL url = new URL(sPath); // URL url = new URL(sPath + "&" + System.currentTimeMillis()); HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); httpConnection.setRequestProperty("User-Agent", "Internet Explorer"); httpConnection.connect(); InputStream input = httpConnection.getInputStream(); byte[] b = new byte[1024]; RandomAccessFile file = getRandomFile(); // 读取网络文件,写入指定的文件中 while ((nRead = input.read(b)) != -1) { String msg = new String(b, 0, nRead, "iso-8859-1"); // System.out.println(msg); if (buffer.length() > 0) { msg = buffer.toString() + msg; buffer.delete(0, buffer.length()); } int pos = msg.indexOf("<!--next-->"); boolean next = pos != -1; int pos_harf = msg.indexOf("<"); boolean harf = (msg.length() - pos_harf) < 11 && pos_harf != -1; if (!next && !harf) { file.write(msg.getBytes("iso-8859-1")); } else if (!next && harf) { buffer.append(msg); continue; } else if (next) { file.write(msg.substring(0, pos).getBytes()); file.close(); buffer.append(msg.substring(pos + 11)); file = getRandomFile(); continue; } } httpConnection.disconnect(); } catch (Exception e) { e.printStackTrace(); } } System.out.println(System.currentTimeMillis()); } static synchronized RandomAccessFile getRandomFile() { try { return new RandomAccessFile("D:\\Android\\LeClient\\bin\\" + System.currentTimeMillis() + ".jpg", "rw"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }?
详细解决方案
Android 单HTTP链接多文件上载
热度:33 发布时间:2016-05-01 17:16:36.0
相关解决方案
- struts HTTP Status 500解决办法
- httpclient老是提示java.lang.NoSuchMethodError: org.apache.http.protocol.BasicHttpCon
- 启动tomcat后,http://localhost:8080无法打开的有关问题
- 相干tomcat HTTP Status 500的疑问,麻烦大家进来看看
- Web Service 错误:服务器未能识别 HTTP 头 SOAPAction 的值: http://tempuri.org/
- HTTP Status 404 - /jspdemo/Register.jsp,该怎么解决
- 'http://reg.163.com/login.jsp?type=1&url=http://entry.mail.163.com/coremail/fcg/,该如何处理
- org.apache.http.client.HttpClient与org.apache.commons.httpclient.HttpClient的差别
- HTTP 404有关问题
- myeclipse<%@ taglib prefix="c" uri="http://java.sun.com/jst1/core_rt"%>解决思路
- ,http 200状态码
- tomcat新手有关问题 HTTP Status 404 - /manager/
- java http 分段上载
- soap调用webservice,报错:Root element of a SOAP message must be: 'http://schemas.xmls,该怎么处理
- HTTP Status 404如何解决
- org.apache.tomcat.util.http.Parameters processParameters,该怎么解决
- 新手,HTTP Status 404 有关问题
- java http 断点上传,该如何处理
- JSP疑问<%@ taglib prefix="ht" uri="http://www.ht.com.cn/jsp/taglibs"%>该怎么处理
- weservice调用Server returned HTTP response code: 500 for URL解决方法
- HTTP Status 404 - /webproject2/servlet/login解决办法
- 报错:HTTP Status 405 - HTTP method GET is not supported by this URL解决思路
- http://newbbs.csdn.net/ 现时和老版的bbs用的还不是同一个库
- http://newbbs.csdn.net/ 现下和老版的bbs用的还不是同一个库
- android 读取byte[]中的元素解决方案
- android 标题栏兑现方式
- android 中Activity向BroadcastReceiver发送数据,该怎么解决
- Android 4.0 为什么模拟器老是提示小弟我谷歌拼音输入法已停止
- android:getSharedPreferences() 这是哪个类的方法解决思路
- android 怎么判断一个程序是否联网