There are more than one ways of doing this. We may use FileWriter
or FileOutputStream
to achieve the purpose. The following sample wraps a FileWriter
with a PrintWriter
to print a String to the file.
Since this is only a demonstration and I don't want to do anything destructive, the program will NOT overwrite any existing file. You may turn on the overwrite mode following the comment below.
No comments:
Post a Comment