• Post Reply Bookmark Topic Watch Topic
  • New Topic

about read() method in filereader class  RSS feed

 
Jian Zhang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Jian Zhang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry but this is the requirement of the teacher , this is my course work ,hehe. I have to use 2d array
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!