Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Need some help with BufferedReader
|
Posted: Jul 11, 2002 2:48 PM
|
|
It looks like you are opening the file twice but only closing once (after the second open).
It is probably not a good idea to have this separate initIn() method; it makes the code harder to read. Since creating the BufferedReader is only one line of code, it would be easier to follow the code if it were opened (and later closed) in the same context where it is used.
Also, maybe you can show the source of the other methods.
Finally, you might consider looking into Collections. It would be a lot more sensible to read the lines into a List of lines, which dynamically grows as you successively add lines to it. At the end of the file-reading process, you can then ask the list how many lines there are. If you really need an array, you can easily convert the list to an array with toArray() at that point and discard the list, if you wish. If you do all this, your code will probably be more than 50% smaller than it is now and a lot easier to understand.
|
|