aspose file tools*
The moose likes Java in General and the fly likes Reading Text file data into an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading Text file data into an array" Watch "Reading Text file data into an array" New topic
Author

Reading Text file data into an array

Mahesh Lohi
Ranch Hand

Joined: Jun 22, 2009
Posts: 150
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

Joined: Oct 13, 2005
Posts: 36453
    
  15
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Reading Text file data into an array
 
Similar Threads
Can we write in a file from an array???
Can we write in a file from an array?
JDBC for loading data into SQL Server
read string from textfile into array
File into object stream