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

Thread: Txt file to array

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Txt file to array

    Hi,

    Lets say I have a text file called "Letter.txt" with a string of 35 numbers stored in it with no spaces.
    i.e. 12345678906435824239

    How would I take this txt file and turn it into an 1d array (not arraylist) with 35 elements(indexes)?

    Any sample code would help me greatly. I have been stuck on this for two days. Thanks.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Txt file to array

    Really? 2 Days . . .

    You can do many things with a String object using the various methods the class provides. You should read through the methods on the String API page to see if any of them sound like something you could use to accomplish this task.

    When you have some code you'ld like help with (if you need it) come back and let us know what help you need.

  3. #3
    Member
    Join Date
    Jul 2013
    Location
    Franklin, TN
    Posts
    47
    Thanks
    3
    Thanked 4 Times in 4 Posts

    Default Re: Txt file to array

    Here this sample code should get you where you need to be...

    public class TextToFileArray {
     
          public static void main(String[] args){
     
          }
    }

    Now that you're started... Show us what you've done, show us what you've tried to do, and we'll point out your errors and assist you in writing it.

Similar Threads

  1. Read txt file into array and create new output.
    By Margaret_Girl87 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: March 19th, 2012, 12:08 PM
  2. [SOLVED] Array Population via .txt File
    By Blackrabbitjack in forum What's Wrong With My Code?
    Replies: 18
    Last Post: March 19th, 2012, 10:07 AM
  3. Building an array from .txt file.
    By brudley5 in forum Object Oriented Programming
    Replies: 3
    Last Post: December 4th, 2011, 09:14 PM
  4. Generating array (or arraylist) matrix from txt file
    By benjalizana in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 14th, 2011, 08:09 PM
  5. Replies: 2
    Last Post: May 13th, 2011, 03:08 AM