Results 1 to 4 of 4
  1. #1
    yap_1991 is offline Member
    Join Date
    Apr 2010
    Posts
    19
    Rep Power
    0

    Default Reading first and last word of each line in a text file

    are there any codes whereby it can read the first and last word of all the lines of a text file?

    I would need to read the first and last word of text files and make sure both the first and last words matches the conditions then print the lines that matches the conditions and save them into a new file.

    Your help is much appreciated.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    My experience in this situation is that it is usually given out as an assignment either for course work or self-study, and that the student gains the most if they in fact don't borrow any code but instead attempt to code it on their own. I strongly suggest you do the same if your goal is to learn Java.

    Much luck!

    edit: and on review of your posting history, I see that you've been told to do your own work for your assignments several times before here. What makes you think that our recommendation for this assignment would be any different? I have to ask-- are you making a decent effort in this course? If not, then now's the time to start. If so, and if nothing is connecting, then you may wish to consider dropping it. There is an art and science to programming, and not everyone has the ability to progress, even very smart people. If this is you, then ending your frustration may be in your best interest.

    Again, much luck.
    Last edited by Fubarable; 06-25-2010 at 06:19 AM.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    My experience in this situation is that it is usually given out as an assignment either for course work or self-study, and that the student gains the most if they in fact don't borrow any code but instead attempt to code it on their own. I strongly suggest you do the same if your goal is to learn Java.

    Much luck!

    edit: and on review of your posting history, I see that you've been told to do your own work for your assignments several times before here. What makes you think that our recommendation for this assignment would be any different? I have to ask-- are you making a decent effort in this course? If not, then now's the time to start. If so, and if nothing is connecting, then you may wish to consider dropping it. There is an art and science to programming, and not everyone has the ability to progress, even very smart people. If this is you, then ending your frustration may be in your best interest.

    Again, much luck.
    This is a great work Fubarable. Thanks for the information. I'm really worried that why people really didn't understand the real meaning/idea of a forum.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by yap_1991 View Post
    are there any codes whereby it can read the first and last word of all the lines of a text file?
    The String.split( ... ) method and a bit of array fiddling are the easiest way out. Now you do the coding and come back here if you're stuck with some technical details, otherwise you have to check rentacoder.com

    kind regards,

    Jos

Similar Threads

  1. Replies: 2
    Last Post: 11-17-2009, 04:12 PM
  2. Reading part of a line in a text file
    By aaronfsimons in forum New To Java
    Replies: 3
    Last Post: 05-04-2009, 07:57 AM
  3. count occurence of word in a line of text
    By sinyi88 in forum New To Java
    Replies: 19
    Last Post: 02-28-2009, 07:37 AM
  4. Replies: 7
    Last Post: 11-19-2008, 02:09 PM
  5. Reading in data from file line by line
    By bluekswing in forum New To Java
    Replies: 1
    Last Post: 10-02-2007, 12:19 AM

Posting Permissions

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