import java.B102`*;
class TextAnalyser
{
   public static void main (String [] args)
   {
      int ch, ndigits = 0, nletters = 0, nother = 0;
      if (args.length != 1)
      {
          System.err.println ("usage: java CA filename");
          return;
      }
      FileInputStream fis = null;
      try
      {
          fis = new FileInputStream (args [0]);
          while ((ch = fis.read ()) != -1)
             if (Character.isLetter ((char) ch))
                 nletters++;
             else
             if (Character.isDigit ((char) ch))
                 ndigits++;
             else
                 nother++;
          System.out.println ("num letters = " + nletters);
          System.out.println ("num digits = " + ndigits);
          System.out.println ("num other = " + nother + "\r\n");
          int total = nletters + ndigits + nother;
          System.out.println ("% letters = " +
                              (double) (100.0 * nletters / total));
          System.out.println ("% digits = " +
                              (double) (100.0 * ndigits / total));
          System.out.println ("% other = " +
                              (double) (100.0 * nother / total));
      }
      catch (IOException e)
      {
          System.err.println (e);
      }
      finally
      {
          try
          {
              fis.close ();
          }
          catch (IOException e)
          {
          }
      }
   }

编译提示:

解决方案 »

  1.   

    把import java.B102`*;
    改成import java.B102.*;
    编译得
      

  2.   

    Exception in thread "main" java.lang.SecurityException: Prohibited package name:
     java
    不要用java作为自己的包名
      

  3.   

    多加两个包import java.io.FileInputStream;
    import java.io.IOException;
      

  4.   

    把你的那个java.B102去掉,java.B102是什么呀?
      

  5.   

    import java.B102`*;
    这句不对,应该是import java.B102.*;另外D:\DOC\JAVA实验\lab4\TextAnalyser.java:15: 找不到符号 
    应该导入Java的IO包
    import java.io.*;
    这样就可以了。
      

  6.   

    网上COPY来的代码,我也疑惑呢!
      

  7.   

    你很多包没有引入,你用编译工具开发不全部解决(eclipse).现在还用白板编程啊。
      

  8.   

    Lz应该学会自己找错误啊。像那句提示语句的意思是在代码的第一行有不可识别的字符,所以就在代码的第一行找啊,发现存在错误import java.B102`*;
      

  9.   

    两种处理方式
    1
    import java.io.FileInputStream;
    import java.io.IOException;public class TextAnalyser {
    public static void main(String[] args) {
    int ch, ndigits = 0, nletters = 0, nother = 0;
    if (args.length != 1) {
    System.err.println("usage: java CA filename");
    return;
    }
    FileInputStream fis = null;
    try {
    fis = new FileInputStream(args[0]);
    while ((ch = fis.read()) != -1)
    if (Character.isLetter((char) ch))
    nletters++;
    else if (Character.isDigit((char) ch))
    ndigits++;
    else
    nother++;
    System.out.println("num letters =" + nletters);
    System.out.println("num digits =" + ndigits);
    System.out.println("num other =" + nother + "\r\n");
    int total = nletters + ndigits + nother;
    System.out.println("% letters ="
    + (double) (100.0 * nletters / total));
    System.out.println("% digits ="
    + (double) (100.0 * ndigits / total));
    System.out.println("% other =" + (double) (100.0 * nother / total));
    } catch (IOException e) {
    System.err.println(e);
    } finally {
    try {
    fis.close();
    } catch (IOException e) {
    }
    }
    }}
    把它放入D盘 通过cmd进行编译
    F:\workspance>javac TextAnalyser.javaF:\workspance>java TextAnalyser d:/a.txt打印结果
    num letters =11
    num digits =0
    num other =6% letters =64.70588235294117
    % digits =0.0
    % other =35.294117647058826
    2种方式
     菜单栏: Configure (配置) -> Options...(选项)   
            在Options 对话框,然后找到JDK  Tools(JDK工具),   
            选择Run  Application(运行应用程序),选中<default>(<默认>),   点击   编辑     
            在Parameters(参数)页面中选中prompt   for   main   method   argument(提示main方法参数)即可

    这回应该知道了把。多动手试试