954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Read text file into two integer arrays

Dear Friends,

This is my homework, I have a text file containing the following content:

0 12 1 15 2 6 3 4 4 3 5 6 6 12 7 8 8 8 9 9 10 13


I want to read these integers from data.txt file and save the two columns into two different arrays in Java.

I am a beginner in Java, and thank you for your help.

sunnynight
Newbie Poster
6 posts since Apr 2010
Reputation Points: 17
Solved Threads: 0
 

We don't actually do people's homework for them here.
Have a try, make a start, when you get stuck come back with a specific question and someone will help.

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

Open the file and read the file line by line (Look up BufferedReader).
Parse the line to get the integers (Look up Tokenization).
Close the file.
It's actually quite simple.

hfx642
Posting Pro
515 posts since Nov 2009
Reputation Points: 248
Solved Threads: 105
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: