【问题标题】:Check if a word exist inside a .txt file (GFI MAX)检查 .txt 文件中是否存在单词 (GFI MAX)
【发布时间】:2014-12-07 16:05:07
【问题描述】:

我需要在 GFI Max 中实现一个脚本,该脚本可以检查文本文件 (.txt) 中是否存在特定单词(比如“完成”)

我希望能够返回 FALSE 或 TRUE 值。

这个脚本可以是js、vbs、cmd、bat。

提前致谢, C

【问题讨论】:

  • 那么是什么阻止了你?
  • 您在 Google 上搜索的时间是否超过 2 秒?
  • 这个问题似乎离题了,因为它没有显示出一点搜索工作,也没有提供代码

标签: windows batch-file text compare


【解决方案1】:

这样做:

public static bool FindWord(String text,String word)
{
String[] words=text.Split(' ');
for(int i=0;i<word.Length();i++)
{
   if(words[i]==word)
     return true;
}
  return false;
}

【讨论】:

  • 您不应该将String 与Java 中的== 进行比较。
  • 所以改为 .equals()
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-24
  • 2022-11-21
相关资源
最近更新 更多