J
justineee
Hi Everyone,
I created this method..
public void loadFile(String[] array)
throws IOException
{
int nWords=0;
FileReader f = new FileReader ("initlist.txt");
Scanner input = new Scanner (f);
while (input.hasNextLine())
{
String blah = input.nextLine();
int lCtr = 0;
array[lCtr] = blah;
lCtr++;
}
input.close();
}
my problem is that the last line is being put in the '0' index of my
array.. I want it to function like one element per line.. I can't
think of other ways to deal with this.
Can somebody help me? Please I'm desperate
Thanks.
I created this method..
public void loadFile(String[] array)
throws IOException
{
int nWords=0;
FileReader f = new FileReader ("initlist.txt");
Scanner input = new Scanner (f);
while (input.hasNextLine())
{
String blah = input.nextLine();
int lCtr = 0;
array[lCtr] = blah;
lCtr++;
}
input.close();
}
my problem is that the last line is being put in the '0' index of my
array.. I want it to function like one element per line.. I can't
think of other ways to deal with this.
Can somebody help me? Please I'm desperate
Thanks.