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 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 异常 400 - Bad Request怎么解决
- Uploadify http error 500解决思路
- []http 500有关问题
- []小弟我上传的网站出现 HTTP 异常 403 - 禁止访问 ,咋回事啊
- HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。该如何解决
- http 怎么获取重定向后的地址
- android 动态设立控件高度
- Android test project 编译方法
- android 4.03启动出错,显示"Encryption Unsuccessful"该如何解决
- Android 下面的listView的动态效果怎么实现的?求源代码,多谢