This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes about read() method in filereader class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "about read() method in filereader class" Watch "about read() method in filereader class" New topic
Author

about read() method in filereader class

Jian Zhang
Greenhorn

Joined: Aug 30, 2003
Posts: 20
I have use the read method in the filereader class to read into a char [],and it returns the number of character have been read. Now I want to read the file in a 2D array. No way to use the same method because the read() method doesn't accept 2d array, and I don't want to the array has any empty contents(since java can't let you change dynamically the length of array).Help please!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8290

a 2d array is probably a bad choice for storage when reading in from a file since you don't know how many read operations you will be performing. Try one of the collections that grow when you add something to it (java.util.ArrayList, for example).


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Jian Zhang
Greenhorn

Joined: Aug 30, 2003
Posts: 20
sorry but this is the requirement of the teacher , this is my course work ,hehe. I have to use 2d array
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: about read() method in filereader class
 
Similar Threads
Reading Array values from a file
Arraay doubt
client locking for URlyBird 1.3.2
AWT Event look for help
Passing Parameters between classes