private DetectorMatch mozillaCheck( String fileName )
  {
    DetectorMatch back = null ;
    nsDetector det = new nsDetector() ;

    // Set an observer...
    // The Notify() will be called when a matching charset is found.

    MyMozillaObserver observer = new MyMozillaObserver() ;

    det.Init( observer ) ;

    try
    {
      File file = new File( fileName ) ;
      BufferedInputStream imp = new BufferedInputStream(
                                    new FileInputStream( file ) ) ;

      byte[] buf = new byte[1024] ;
      int len ;
      boolean done = false ;
      boolean isAscii = true ;

      while ( (!done) && ((len = imp.read( buf, 0, buf.length)) != -1 ))
      {

        // Check if the stream is only ascii.
        if ( isAscii )
        {
          isAscii = det.isAscii( buf, len ) ;
        }

        // DoIt if non-ascii and not done yet.
        if ( !isAscii && !done )
        {
          done = det.DoIt( buf, len, false ) ;
        }
      }
      det.DataEnd() ;

      back = observer.getMatch() ;

      if (back == null) // nothing was found, try to present a probable result
      {
         String prob[] = det.getProbableCharsets() ;
         if (prob != null)
         {
           if (prob.length > 0)
           {
             back = new DetectorMatch( prob[0], "", 0) ;
           }
         }
      }

    }
    catch (Exception e)
    {
      System.out.println( "ERROR" ) ;
    }


    return back ;
  }