Good start for a newbie
.
Now let's see what we can improve in the code.
To start off with lets reduce the File I/O.
1. BufferedReader reader = new BufferedReader(new FileReader("test.txt"));
......
while((in = reader.readLine()) != null)
You are reading the file twice, first time to check the number of lines in the file and second time the actual content, the size of the array cannot be changed at runtime and hence I suppose you have gone for the above approach.
will it be ok for you if you read the lines into an arraylist and convert it into the string[], or do you "not" want to use collections at all and work only with the String [].
If reading into the arraylist and then converting into the string [] is ok with you, the API for collection classes provides you with the methods to return the content of the list in an [] format.
If you do not want to use any collection classes like ArrayList, Vector etc what you could do is while reading from the file you can keep on concating the content of the readline to a string but seperated by a token.
you can then use the tokenizer method to collect the differnt tokens into your String[].
2. Unless you have some reasons for storing each line in a different [] element, the better way to go about it is construct a single String for the whole file content.
PS:
BufferedReader reader = new BufferedReader ...... that a good start for a newbie......