java中,怎样判断指定文件中含有某一个字符串(如abcd)

如题所述

public static void main(String[] args)
 {
  String str="abcd";
  if(str.indexOf("abcd")!=-1){
   System.out.println("包含");
  }else{
   System.out.println("不包含");
  }
 }

追问

是一个文件中含有这个字符串,而不是字符串中含有这个字符串

温馨提示:答案为网友推荐,仅供参考
相似回答