将元素继承Comparator接口,调用元素Collection的contains方法,不知道对不对,你可以试一下

解决方案 »

  1.   

    java.lang.reflect.Array.getLength(obj);如果不是数组会抛出IllegalArgumentException异常的
      

  2.   

    是我没写得很清楚是这样java中有没有判断一个元素是不是数组中的元素的方法?
    或者说判断一个元素是不是在数组中的方法
      

  3.   

    areshong(strength&honor) 我没明白,元素怎么继承接口?你能详细点吗?
      

  4.   

    自己写一个循环就搞掂啦,这么烦
    for(int i = 0; i < arr.length; i++) {
      Object a = arr[i];
      if(a.equals(src))
        return i;
    }
    return -1;
      

  5.   

    把数组中所有的元素放到哈希表中作为key,数组下标作为value, HashTable Or HashMap,然后使用get(key)方法判断取出来的是不是null,不是就说明包含啦!好像绕了一个圈子。:)
      

  6.   

    用ArrayList的boolean contains(Object elem)方法可以判断。
      

  7.   

    问题解决了,用的 bestdelphier(我是一只小小小菜鸟) 的方法 public void delMPic(String info_id,String realPath)throws Exception{
    infoParam param = null;
    String fileName = "";
    String infoFile = "";
    String fun_id = "";
    File folder = null;
    String nameList[] = null;
    String ss = "";
    //System.out.print("heloooooo");

    try {
    param = getInfoParam(info_id);
    fun_id = param.getFun_id();
    int m=0,q =0;
    folder = new File(realPath+"\\upload\\images\\"+fun_id+"\\");
    nameList = folder.list();
    ArrayList slist = new ArrayList();//图片文件夹中的该条记录的图片(简称文件夹)
    ArrayList alist = new ArrayList();//更新后内容中所包含的图片(简称内容)

    //初始化文件夹
    for(int j=0;j<nameList.length;j++){
    q=nameList[j].indexOf("_");
    ss=nameList[j].substring(0,q);

    if(ss.equals(info_id.trim())){
    slist.add(nameList[j]);
    }
    }
    /*for(int y=0;y<slist.size();y++){
    System.out.print("[[[[["+slist.get(y)+"]]]]");

    }*/

    //初始化内容
    String strcontent = param.getInfo_content();
    String strBegin = "<IMG src=\"";
    String strEnd = "\">";
    int nBegin = 0;
    int nEnd = 0;
    nBegin = strcontent.indexOf(strBegin, nBegin);
    nEnd = 0;
    while(nBegin != -1){
    nEnd = strcontent.indexOf(strEnd, nBegin);
    String strTmp = strcontent.substring(nBegin, nEnd+2);
    String strTmp1 = strTmp.substring(18,strTmp.lastIndexOf("\">"));
    fileName=strTmp1.substring(+strTmp1.lastIndexOf("/")+1);
    alist.add(fileName);
    nBegin = nEnd + 1;
    nBegin = strcontent.indexOf(strBegin, nBegin);
    }

        //判断文件夹中的图片是否在更新后的内容中
    for(int w=0;w<slist.size();w++){
    if(!alist.contains(slist.get(w))){
    deleteFileSin(realPath+"\\upload\\images\\"+fun_id+"\\"+slist.get(w));
    }
    }
    }catch (Exception e) {
    e.printStackTrace();
    throw new Exception("删除修改图片错误:错误信息为"+e.getMessage());

    }
    }
      

  8.   

    唉,我也想到了bestdelphier(我是一只小小小菜鸟) 的方法。
    就这样眼看着分白白的流逝。。
    呵呵