## Java data lists

In this forum members can discuss topics about specific programming languages.
pr022
Posts: 2
Joined: Sat Jun 16, 2012 9:33 am

### Java data lists

Hi. I have been having trouble finding efficient ways to import data from an outside source in java, and projecteuler is making this problem more annoying for me. Some of the .txt files (especially 54, what i'm on right now) seem to be very difficult to use. I'm not sure if i'm getting my question across correctly -- specifically right now, i'm having trouble taking the information from a .txt file like poker.txt and putting it into a form for java to use. Any tips with this? Thanks

jaap
Posts: 551
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

### Re: Java data lists

Here's a simple bit of code to read a text file line by line.

Code: Select all

   public static void main(String[] args) throws IOException {
// read first line of text
while(s!=null){
// do something with this line of text
System.out.println(s);
}
}

You'll have to figure out what to do with each line yourself, but you may find that the String member functions charAt and split come in handy.

pr022
Posts: 2
Joined: Sat Jun 16, 2012 9:33 am

### Re: Java data lists

First..jaap? you have no idea how many time's i've been to your site. Thank you so much

And thanks for the answer - it was perfect! Kudos to you, mr. amazing