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
相关解决方案
- HTTP Status 404 - /jspdemo/Register.jsp,该怎么解决
- org.apache.http.client.HttpClient与org.apache.commons.httpclient.HttpClient的差别
- ,http 200状态码
- tomcat新手有关问题 HTTP Status 404 - /manager/
- android 读取byte[]中的元素解决方案
- android 标题栏兑现方式
- android 中Activity向BroadcastReceiver发送数据,该怎么解决
- Android 4.0 为什么模拟器老是提示小弟我谷歌拼音输入法已停止
- android:getSharedPreferences() 这是哪个类的方法解决思路
- android 怎么判断一个程序是否联网
- android RadioButton如何设置默认选中
- http 传送数据 每个包有大小限制码?解决办法
- android 怎么重新设置锚点
- android 图片对象获取的有关问题
- android 关于服务连接的疑义
- android 怎么实现对view的放大和缩小
- android ID,该如何处理
- 准备复习2-3个月,看java+android,请问有经验者,怎么看效果最好》
- android UI线程与AsyncTask的有关问题
- android(java) 中文乱码的有关问题
- 急关于Windows Server 2008 的 iis 7 下的aspx页面“HTTP 异常 404.3 - Not Found”异常
- HTTP 异常 405.0 - Method Not Allowed
- HTTP 异常 401.3 - 未经授权:访问由于 ACL 对所请求资源的设置被拒绝
- HTTP 异常 400 - Bad Request怎么解决
- HTTP 405异常
- iis HTTP/1.1 新建应用程序失败,父路径等基本设置都已更改,但还是不能访问解决方案
- Uploadify http error 500解决思路
- HTTP modules are called as part of the ASP.NET request pipeline and have access to life cycle events throughout the request.解决办法
- []http 500有关问题
- win2003企业版,安装之后运行ASP文件出现:HTTP 异常 404 - 文件或目录未找到