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 2 of 2

Thread: Reading from one file and write certain strings to another file

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Reading from one file and write certain strings to another file

    Hey, I'm pretty rusty as I haven't coded in a while but basically I need to:

    Read through a text file that has many 16 char strings in the format "123456789_123456", some of which are appended to each other on the same line e.g. "123456789_123456123456789_123456123456789_123 456" that would be 3 of these 16 char strings appended to one another. I need to put strings in a new text file which their last 2 digits equals "00" and place all the found strings on a new line each.

    Can anyone provide any assistance? I know how to open files and read and write to them. I just don't know how to specifically search through it to look for the last 2 digits of a string and then put it in a new file with each string being on a new line.

    Any assistance greatly appreciated!

    Thank you.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,104
    My Mood
    Mellow
    Thanks
    244
    Thanked 755 Times in 741 Posts

    Default Re: Reading from one file and write certain strings to another file

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Refer to the String API for the available methods. There are a few there you should find helpful. You've shown some variation in the 16-character Strings that might be a challenge but nothing that can't be overcome once all of the possible variations are understood.

Similar Threads

  1. Replies: 6
    Last Post: March 16th, 2014, 09:03 PM
  2. PrintStream, strings and reading from a file.
    By taze in forum What's Wrong With My Code?
    Replies: 13
    Last Post: November 1st, 2013, 09:50 PM
  3. Replies: 3
    Last Post: December 2nd, 2011, 11:53 AM
  4. Java I/O File code; how to read/write file
    By ryu2le in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 18th, 2011, 06:51 PM
  5. reading content of the text file, splitting it into strings
    By Dodo in forum File I/O & Other I/O Streams
    Replies: 7
    Last Post: January 6th, 2011, 07:57 PM