Jeff Verdegan wrote:Inside your while loop, you're overwriting the previous file each time, so the file will only contain the last item. Open the stream before the loop, write inside the loop, and close it after the loop, in a finally block. (Or use Java 7's "with resources".)
Marco Galea wrote:
Jeff Verdegan wrote:Inside your while loop, you're overwriting the previous file each time, so the file will only contain the last item. Open the stream before the loop, write inside the loop, and close it after the loop, in a finally block. (Or use Java 7's "with resources".)
Hi Jeff, first of all thanks, secondly do you mean the loop in the Import() ??
and another question please... what do you actually mean by handle the IOException. ??
Marco Galea wrote:another thing please !!! if i did ,true after the filename and leaving the loop as it is, wouldn't i be solving the problem you mentioned about overriding each time ??
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:It is from Java 7 on:
If you're using Java 6 or an even older version you have no choice but to use two distinct catch statements.
However, you shouldn't need to catch NullPointerException at all. You should instead prevent it by adding the necessary checks.
Marco Galea wrote:i suppose i can use also the & operator instead of | ??
as for the null exception... they were the first two exceptions that came to my mind but alas its good to know that its not good practice to catch them.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Don't get me started about those stupid light bulbs. |