5. ข้อความ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 5-17  โปรแกรมตรวจคำสะกดผิด (ต่อจากรหัสที่ 5-16)
    Scanner kb = new Scanner(System.in);
    System.out.print("แฟ้ม = ");
    String inputFile = kb.nextLine();  // ลอง c:/java101/anthem.txt
    WordScanner file = new WordScanner(new File(inputFile));
    System.out.println("คำที่ไม่พบในพจนานุกรมมีดังนี้ : ");
    while (file.hasNext()) {
      String word = file.nextWord();
      word = word.trim();
      if(riwords.indexOf("$"+word+"$")<0) {
        System.out.println(word);
      }
    }
  }
}
©2009 S.Prasitjutrakul