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 blocke.printStackTrace();}return null;}

更多相关文章

  1. 垂直的SeekBar
  2. android实现通知栏透明
  3. Android(安卓)VNC Server
  4. eclipse中查看android的SDK源代码
  5. Android(安卓)使用 URL 和 AsyncTask 加载网络数据
  6. android创建txt文件,读取txt文件内容
  7. Android第十二课 jni函数的静态绑定
  8. Android(安卓)采用pull解析xml文件

随机推荐

  1. Effective MySQL之深入解析复制技术
  2. 在arcpy中删除或删除表的代码是什么?
  3. oracle11g 创建id自增长监听器的步骤
  4. 在SQL SELECT语句中重用别名字段
  5. 用javabean连接sql server 2000数据库报
  6. CentOS下MySQL主从同步配置 ​Slave_IO_R
  7. 使用IN语句缓慢mysql删除查询
  8. mysql的replace的使用
  9. 无需安装ORACLE远程连接SQLPLUS以及PL/SQ
  10. (转)运维角度浅谈MySQL数据库优化