首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

施用广播机制来完成版本更新模块(详解)

2012-07-01 
运用广播机制来完成版本更新模块(详解)先看下主配置文件:再看下主控制类:下面来看下后台服务下载的代码:pa

运用广播机制来完成版本更新模块(详解)
先看下主配置文件:



再看下主控制类:



下面来看下后台服务下载的代码:
package com.xiaoma.utils;  import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL;  /**  * @Title: DeleteFile.java  * @Description: 文件、文件夹操作类  * @author MZH  */ public class FileUtils{     private URL url = null ;     public FileUtils(){     }          public File writeInput(String PathName, InputStream input){         File file = null;         OutputStream output = null;         try{             file = new File( PathName );             if (file.exists())                 return file;                              int length = 0;             output = new FileOutputStream(file);             byte buffer[] = new byte[1024];             while((length = input.read(buffer)) > 0){                 output.write(buffer, 0, length);             }                      }catch(Exception e){             e.printStackTrace();         }finally{             try{                 output.close();             }catch(Exception e){                 e.printStackTrace();             }         }                  return file;     }          public InputStream getStreamFromUrl(String urlStr)             throws MalformedURLException, IOException {         url = new URL(urlStr);         HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();         InputStream inputStream = urlConn.getInputStream();         return inputStream;     } } 

热点排行