Please avoid editing your posts after they have been replied to; in this case it does no harm, so I shall let the changes stand. You have added the whole code to your original post.
Please beware of comments; a comment should always clarify things, but some, e.g.
...add nothing new. Please don't write
ALL UPPER CASE. That comment does raise a question: why have you not written a constructor for that class? I don't like default constructors.
Some other comments, e.g.
...are incorrect. That doesn't write anything to the file.
You appear to be opening the print writer and closing it before using it. Anyway, that isn't the correct way to close your writer. Look in the
Java™ Tutorials.
You can wrap that sort of code in a loop, but it really merits a method to itself, in which case I would allow the exception to propagate by deleting the
catch and declaring that the method
throws FileNotFoundException.
It might be worth finding out how to use a
JFileChooser to choose the files.
I think you should move reading and writing the files into different methods. Your file reading can be called from a constructor, but methods called from a constructor should have
private access
or be marked
final. (It is not necessary for a method to be both
final and
private.) Again don't call
close() on a Scanner, but use try with resources instead.
I don't like
nextLine() on Scanners; it is better if at all possible to divide the line into parts and read the individual parts with
next(),
nextInt(),
nextBigDecimal(),
etc.
Don't write
== true or
== false. Both are poor style and error‑prone because you might write
= by mistake.
Never
while (b == true) ... please.
Always
while (b) ... please.
Never
while (b == false) ... please.
Always
while (!b) ... please.
[edit] Sorry I was mistaken; you do appear to be writing something in that file. I have
struck out the line where I was mistaken above. The line l5 I mentioned doesn't write anything to the file. It might create the file, but any writing occurs later.