Proplem with reading txt-file into array //null
I found a closed string here on how to sort the 'not reading the first line' -problem with removing the 'while' .
Then comes the next problem, how do i stop the reading when there is nothing more ro read?
This is what I have at the moment
Code:
import java.io.*;
class FileRead
{
public static void main(String args[])
{
try{
FileInputStream fstream = new FileInputStream("textfile.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
// while ((strLine = br.readLine()) != null) {
String[] store;
store = new String[10];
for (int j = 0; j < store.length; j++){
store[j] = br.readLine();
System.out.println(store[j]);
}
// }
in.close();
}catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
}
}
And in the txt page i have:
one
two
three
four five
...
The General Output says:
--------------------Configuration: <Default>--------------------
one
two
three
four five
...
null
null
null
null
null
Process completed.
//How do i stop at the '...'?
Please help me
Thanks
/Zen