Nullpointer Exception with BufferedWriter?
I'm trying to write out a String array to a text file using a Buffered Writer.
It works fine when the array has 100 values but when I go higher than that it gives me a NullPointerException caused by the write() method.
This is my assignment code:
Code:
BufferedWriter writer = new BufferedWriter(new PrintWriter(file));
This is my enhanced for loop and closing code:
Code:
for(String s : usernames) {
writer.write(s);
writer.newLine();
}
writer.flush();
writer.close();
I'm guessing this is because String[] arrays can't hold that much memory, if so what can I use to duplicate what I want?
Thanks a lot,
~Solarsonic