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

Thread: Splitting String

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Splitting String

    Dear members,

    I'm new here first off.. my name is Julian.. (: nice to meet y'all...

    (Im new to java aswell)

    ....

    Would like some help regarding the split("|") method, I'm trying to retrieve information line by line from a text file and splitting each line into an array.

    till now I only came as far as:

    String textToSplit = "Hello|this is the text I want to|split";
    textToSplit.split("|");

    I have no idea of how to do the rest, can someone explain please? thank you


  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Splitting String

    Found the solution to put the splitted text into an array, but have no idea of how to read from text file.. can someone help?

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Splitting String

    how to read from text file
    Look at the Scanner class for a quick and easy way to read lines from a text file.
    Do a Search on the forum for many code samples.

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

    Default Re: Splitting String

    Thanks dude

Similar Threads

  1. [SOLVED] Splitting a txt file with multiple spaces
    By macko in forum File I/O & Other I/O Streams
    Replies: 11
    Last Post: November 1st, 2011, 01:03 PM
  2. [SOLVED] Splitting String by Multiple Delimiters
    By relixus in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 4th, 2011, 08:54 PM
  3. Splitting an Array?
    By ThatGuy1234 in forum Java Theory & Questions
    Replies: 1
    Last Post: January 19th, 2011, 08:20 AM
  4. 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
  5. Splitting File into Array
    By Scottj996 in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: March 3rd, 2010, 11:48 AM