Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Norm

Thread: Need help with program - please

  1. #1
    kepler is offline Member
    Join Date
    Mar 2015
    Posts
    7
    Rep Power
    0

    Question Need help with program - please

    Good afternoon,

    I was wondering if it's possible to do this: I want to build a java program that reads a java array from a text file.
    Then I want to read it, and output it in a different format.

    The reading and out is easy - as text.

    But how can I incorporate the read text in to a java valid array in my program, which I can use?

    Is this even possible?

    Kind regards,

    Kepler

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Need help with program - please

    how can I incorporate the read text in to a java valid array
    Use a loop to read each data item from the file and assign it to an element of the array.
    A problem can be knowing how large to define the array so all the items will fit without going past the end of the array.
    kepler likes this.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    kepler is offline Member
    Join Date
    Mar 2015
    Posts
    7
    Rep Power
    0

    Default Re: Need help with program - please

    Hello,

    I'm sorry - I missed a point. The text file has a java structure array code. Like:

    Java Code:
    private static final double[] A0 = {9.922274, 10.016090, -3.947474};
    Is it possible to parse lines like this?

    Kind regards,

    Kepler

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Need help with program - please

    So you are actually literally reading data from a java source file?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Need help with program - please

    Quote Originally Posted by kepler View Post

    Java Code:
    private static final double[] A0 = {9.922274, 10.016090, -3.947474};
    Is it possible to parse lines like this?
    Of course! compilers do it all the time.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Need help with program - please

    Quote Originally Posted by kepler View Post
    Need help with program - please
    Please go through the Forum Rules, particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 6
    Last Post: 12-15-2013, 06:40 AM
  2. Replies: 4
    Last Post: 11-21-2012, 01:19 PM
  3. Replies: 2
    Last Post: 04-02-2011, 12:57 PM
  4. Replies: 13
    Last Post: 03-22-2011, 06:49 AM
  5. changing my program to array working program
    By Chewart in forum New To Java
    Replies: 39
    Last Post: 11-18-2009, 06:53 PM

Posting Permissions

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