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-16  ส่วนของโปรแกรมสร้างสตริงเก็บคำศัพท์ต่างๆ
import java.util.Scanner;
import java.io.*;
import jlab.WordScanner;
// โปรแกรมตรวจคำสะกดผิด 
public class SpellChecking {
  public static void main(String[] args) throws IOException {
    Scanner in = new Scanner(new File("c:/java101/riwords.txt"));
    PrintStream out = new PrintStream(new File("c:/java101/t.txt"));
    out.print("$");
    while (in.hasNext()) {
      String line = in.nextLine();
      line = line.trim();
      if (line.length() > 0 && !"#".equals(line.substring(0, 1))) {
        out.print(line + "$");
      }
    }
    out.close();
    Scanner tmp = new Scanner(new File("c:/java101/t.txt"));
    String riwords = tmp.nextLine();
©2009 S.Prasitjutrakul