小的是新手!!
在android下通过http下载服务器上的一个文本文件!!
android平台下的代码写好 了!
但是不知道服务器端要怎样部署!!
用的是tomcat!!!

解决方案 »

  1.   

    刚好前几天写了这个功能,
    private String urlDownload = "http://下载路径";
    private String dirName = "/mnt/sdcard/";//保存到SD卡
        private Activity activity;
        public InputStream in;
        //开始下载
        public void getDownloader(Activity conuter){
    File f = new File(dirName);
    if(!f.exists())
    {
    f.mkdir();
    }
    activity=conuter;
    //启动文件下载线程
    thread.start();

        }
        Thread thread=new Thread(new Runnable() {
    @Override
    public void run() {
    // TODO Auto-generated method stub
    //准备拼接新的文件名(保存在存储卡后的文件名)
    String newFilename = urlDownload.substring(urlDownload.lastIndexOf("/")+1);
    newFilename = dirName + newFilename;
    File file = new File(newFilename);
    //如果目标文件已经存在,则删除。产生覆盖旧文件的效果
    if(file.exists())
    {
        file.delete();
    }
    try {
        if(getOpenUrl(urlDownload)==true){
         System.out.println("开始下载");
        // 1K的数据缓冲    
        byte[] bs = new byte[1024];    
        // 读取到的数据长度    
        int len;    
       // 输出的文件流    
        OutputStream os = new FileOutputStream(newFilename); 
        // 开始读取    
        while ((len = in.read(bs)) != -1) {  
          os.write(bs, 0, len);    
        }  
        System.out.println("下载完成");
        // 完毕,关闭所有链接   
        os.close();   
        in.close(); 
        thread.stop();
        goIntenExtra();

        } } catch (Exception e) {
    e.printStackTrace();
    System.out.println("出错了");
     
    }
    }
    });
      

  2.   

    项目根路径下 随便放
    提供个参考的 D:\soft\work\apache-tomcat-6.0.29\webapps\manager 
      

  3.   

    不太明白你的意思,只要是个web服务器就可以吧。