Results 1 to 6 of 6

Thread: How do you read each line of a text area???

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    90

    How do you read each line of a text area???

    I was woundering if any one knows how to read each line from a text area.

    i think it has something to do with this but i am not sure:
    Code:
    textStorge = textArea.read(Reader());
    CaM

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: How do you read each line of a text area???

    Sorry I can't be more specific, but maybe with the IndexOf and subString methods and a loop you can do something?


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    90

    Re: How do you read each line of a text area???

    i dont really understand

    does anyone else hav any ideas???
    CaM

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: How do you read each line of a text area???

    Ive been trying to figure out how to do this also but i dont think that it can be done with most of the methods from the JTextArea class. There is getText(int offs, int len) but there is noway to get the width of what is contained in the column only the number of columns that are set when the JTextArea is created. So getColumns() is no good. So is getRows(). getLineCount() would be good to use but we would still need the column count. They should have a method that represents the JTextArea() as a matrix getText(int row, int col, int offs, int len) .

    What about read(Reader in, Object desc)? Anybody figure out how to use it?

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: How do you read each line of a text area???

    I think we want to write not read. I think reading goes into the JTextArea. To get the contents whether line by line or the whole thing we need to write.

    I figured out how to write the contents of a JTextArea to a file but i couldn't figure out a way to write line by line. Too bad we couldn't use BufferedReader's readLine().
    Code:
    BufferedWriter buff = new BufferedWriter(new FileWriter("C:\\test.txt"));
    jta.write(buff);

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    90

    Re: How do you read each line of a text area???

    Yeah i know it is too bad that we could not use buuffereed readers.

    I will try to use the write command insted of the read command

    thanks
    CaM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width