没有这么麻烦的,下面是使用FileChannel下载文件的代码:
  /**
     * 使用文件通道下载本地文件
     * @param source 本地文件路径
     * @param target 下载保存路径
     * 
     */
    public static void downLoadFile(String source,String target) throws FileNotFoundException, IOException{
        FileInputStream fi=new FileInputStream(source);
        FileOutputStream fo=new FileOutputStream(target);
        FileChannel ci=fi.getChannel();
        FileChannel co=fo.getChannel();
        co.transferFrom(co, 0, (new File(source)).length());
        co.close();ci.close();fi.close();fo.close();
    }FileChannel如果不需要使用缓冲区移动修改的话,用上面的下载。
如果需要进行update到server上,就需要控制缓冲区了,差不多就是你的代码的样子。

解决方案 »

  1.   

    //List1---------------------------------
    for(int i=0,j=0,tmp=0;i<tab[k].length();i++){if(tab[k].charAt(i)==','){j++;}
    if(j==1){type_8points_inpout.List1.add(tab[k].substring(tmp,i));break;}
    if(tab[k].charAt(i)==','){tmp=i+1;}
      }
    //List1---------------------------------
    //List2---------------------------------
    for(int i=0,j=0,tmp=0;i<tab[k].length();i++){
    if(tab[k].charAt(i)==','){j++;}
    if(j==2){type_8points_inpout.List2.add(tab[k].substring(tmp,i));break;}
    if(tab[k].charAt(i)==','){tmp=i+1;}
          }
    //List2--------------------------------- //List3时间---------------------------------
    //ect..........很多别的list 
    =====================================================
    1. List1, List2, ..., ListN 可以放在一个 List 里,List<List> lists, getList(int index) 取得list
    2. 下面的代码可以放在一个函数里
    for(int i=0,j=0,tmp=0;i<tab[k].length();i++){
    if(tab[k].charAt(i)==','){j++;}
    if(j==2){type_8points_inpout.List2.add(tab[k].substring(tmp,i));break;}
    if(tab[k].charAt(i)==','){tmp=i+1;}
          }void func(int index, other params) {
    for(int i=0,j=0,tmp=0;i<tab[k].length();i++){
    if(tab[k].charAt(i)==','){j++;}
    if(j==2){type_8points_inpout.getList(i).add(tab[k].substring(tmp,i));break;}
    if(tab[k].charAt(i)==','){tmp=i+1;}
          }
    }3. 那一堆访问 list 的代码可以用一个循环来访问。
      

  2.   

    http://bbs.csdn.net/topics/
    谢谢 不过我这个需要在缓冲区操作 感觉挺难优化:D