import java.io.*;public class Find1 {
  public static void main(String[] args) {
      if (args.length !=1) {
         System.out.println("使用法:java Find1 检索文字列《检索对象文件》");
         System.out.println("例:jfldsflkdsfjlsd");
         System.out.exit(0);
       }
       String findsring=args[0];
       System.out.println("检索文字列是["+findstring+"]");
       BufferedReader Reader=new BufferedReader (new InputStreamReader(System.in),1);
       try  {
          String line;
          int linenum=1;
         while ((line=Reader.readline())!=null) {
          int n=line.indexof(findstring);
          if (n>=0) {
             System.out.println(linenum+":"+line);
            }
            linenum++;
          }
          }catch (IOException e) {
          System.out.println(e);
          }
       }
     }

解决方案 »

  1.   

    int n=line.indexOf(findstring);
    System.exit(0);
    while ((line=Reader.readLine())!=null) {
    String findstring=args[0];
      

  2.   

    //编译成功,但是运行可能有问题import java.io.*;public class Find1 
    {
      public static void main(String[] args) 
      {
          if (args.length !=1) 
          {
             System.out.println("使用法:java Find1 检索文字列《检索对象文件》");
             System.out.println("例:jfldsflkdsfjlsd");
             System.exit(0);
          }
          String findstring=args[0];
          System.out.println("检索文字列是["+findstring+"]");
          BufferedReader Reader=new BufferedReader (new InputStreamReader(System.in),1);
          try  
          {
              String line;
              int linenum=1;
              while ((line=Reader.readLine())!=null) 
              {
                 int n=line.indexOf(findstring);
                 if (n>=0) 
                 {
                 System.out.println(linenum+":"+line);
                  }
                 linenum++;
              }
          }catch (IOException e) {System.out.println(e);}
      }
    }
      

  3.   

    String findsring=args[0];有可能导致数组越界
      

  4.   

    BufferedReader Reader:
    BufferedReader是个类,
    Reader也是个类,怎么可以这样声明呢!!!
      

  5.   

    第一个问题;  
    System.out.exit(0);
    应该是System.exit(0)。
    第二个问题
     BufferedReader Reader中的Reader是关键字,不能做用户变量。
      

  6.   

    谢谢各位的帮助,本人经过琢磨,发现问题出现在
     System.out.exit(0);
    这个地方,去掉这个就可以完全运行了。。呵呵。。谢谢大家哟public class Find1 
    {
      public static void main(String[] args) 
      {
         
         System.out.println("使用法:java Find1 检索文字列《检索对象文件》");
         System.out.println("例:jfldsflkdsfjlsd");
         String findstring=args[0];
         System.out.println("检索文字列是["+findstring+"]");
         BufferedReader sha=new BufferedReader (new InputStreamReader(System.in),1);
         try  
         {
            String line;
            int linenum=1;
            while ((line=sha.readLine())!=null) 
            {
              int n=line.indexOf(findstring);
              if (n>=0) 
              {
              System.out.println(linenum+":"+line);
                }
              linenum++;
            }
         }catch (IOException e) {System.out.println(e);}
      }
    }
      

  7.   

    http://www.quandi.cn/WebForm1.aspx?quandi_id=lxzm1001java不懂了。呵呵