Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7651535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:31:53+00:00 2026-05-31T11:31:53+00:00

I have a text file with a list of doubles. The first value of

  • 0

I have a text file with a list of doubles. The first value of the line is the x value and the second value is the y value.

  103.0 274.0
  133.0 383.0
  342.0 250.0
  204.0 126.0
  177.0 357.0
  ...

How can I read these values and load them into an array list?

  ArrayList<Point> store = new ArrayList<Point>();


                  File file = fc.getSelectedFile();

               StringBuilder all = new StringBuilder();

               BufferedReader reader = new BufferedReader( new FileReader(file));
               String input = null;
               while ((input = reader.readLine()) != null)
               {
                 String a =  all.append(input+"\n").toString();

                 String[] hold = a.split(" ");

                double x =  Double.parseDouble(hold[0]);
                int aa = (int)(x);
                double y = Double.parseDouble(hold[1]);
                int bb = (int)(y);

                store.add(new Point(aa, bb));
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:31:55+00:00Added an answer on May 31, 2026 at 11:31 am
    1: Get an input stream of the file.
    2: read line by line using readLine() method
    3: split the string by SPACE using split() method of String class
    4: the String array you got has two elements now.
    5: Double.parseDouble(array[0]) and Double.parseDouble(array[1]) are value of x and y
    6: store these values into the corresponding values of Point object
    7: add that point object to ArrayList.
    8: Done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text file with something like first line line nr 2 line three
I have a text file with a list of macro names (one per line).
I have a text file that contains a list of filenames, minus the extension,
I have a list of timestamps in a text file. I want to figure
I have a list Dogs in a text file with the following format: id:fatherid:motherid:born:owner:breed
I have a small Java program that reads list of IPs from text file
Okay, basically, I have a large list of phone numbers in a text file
I have a text file that has a very long list of items. So
I have a text file like list: -----> 2012-02-13 19:29:27.325 <http-0.0.0.0-9090-1> at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236) at
I have text file containing a list of 16 bit hex numbers (e.g. '61C7393AA9B3474DB081C7B7CCE1C545')

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.