Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Primitive text editor

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Primitive text editor

    Hi, I need to code a primitive text editor for school that can edit text files with the following methods:

    1. String spellCheck () // finds the first occurrence of spelling error and returns the misspelled word. If no word is misspelled returns "Spell Check Passed".
    2. void spellCheckAll() // find all misspelled words and output them to the screen.

    These methods are supposed to use a text file of some 10,000 words as their "dictionary." The methods will need to be applied to long text files (300+ page books). I was planning on representing the text files as huge Strings, but I'm not sure how I would search through them word by word to compare to my dictionary list. I could change the way that I represent the files in memory, but Strings seem to be the most convenient data structure for the other methods I need for the editor. Can anyone help?

    Thanks for your help


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Primitive text editor

    Hello and welcome to the forums.

    I suggest you play with:

    http://www.javaprogrammingforums.com...ner-class.html

    More file manipulation codes here:

    File Input/Output Tutorials
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Primitive text editor

    I know how to read and write files line by line, just not word by word. I guess I could search for blank spaces and create strings from whatever's in between. It just seems like there must be an easy way to scan a string word by word.

  4. #4
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Primitive text editor

    Use Java swing as desktop application
    Use Java + GWT plugin as web text editor application


    __________________________________________________ ___________________
    Make your own flash game

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Primitive text editor

    // reading command file, assigning it to RandomAccessFile for traversing.
    File inputFile = new File(commandFile);
    RandomAccessFile raf = new RandomAccessFile(inputFile, "r");
    String theLine = raf.readLine();

    while (theLine!= null)
    {
    //whitespace before and after the string is removed.
    theLine = theLine.trim();
    //split the current line. Put each token into array.
    String [] tokens = theLine.split("\\s+");

Similar Threads

  1. Tutorial: Primitive Data Types
    By newbie in forum Java Programming Tutorials
    Replies: 3
    Last Post: July 5th, 2012, 11:56 PM
  2. Primitive data type
    By stuart harper in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 17th, 2011, 12:14 PM
  3. Replies: 2
    Last Post: June 27th, 2011, 11:14 AM
  4. Text editor and command line
    By cl2606 in forum Java IDEs
    Replies: 2
    Last Post: June 8th, 2011, 08:20 AM
  5. making text editor using string class
    By petadeer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 14th, 2011, 03:28 AM