• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading Text file data into an array  RSS feed

 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I would like to know if I can read the text file data into an array. Each word in my text file should be stored into array.

Thank you in advance..

 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to count the lines first, then you know what size of array to use. Then reading into the array is quite easy.

Might be better to read into a List<String> then convert the List to an array, because that saves you the counting.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!