a) I'm having difficulty finding the best way to output text to a file (to
create an html document). I have discovered there are several ways to do
this... which is the best?
I read that FileWriter is one of the best ways to do this.
b) How do I write a newline character? the standard "obj.write('\n');"
writes a special character. Or at least, my non-unicode(?) MS Notepad sees
a special character. Makes the source code a little messy.
Greg Johnson
gdbjo...@hotmail.com
Matt
In article <GQe76.44639$n%.2346476@news20.bellglobal.com>,
Sent via Deja.com
http://www.deja.com/
Actually, I think FileWriter is a stupid class that should not exist. It
hides the character encoding issues by only supporting the platform default
encoding. If you look at the source for FileWriter all it has are
constructors. The expression:
new FileWriter( foo )
is simply shorthand for
new OutputStreamWriter( new FileOutputStream( foo ) )
with the exception that with the OutputStreamWriter you can also specify an
encoding.
--
Dale King
Or, if you do use a BufferedWriter, call the newLine() method.
Here's the Sun documentation for this method:
"A newLine() method is provided, which uses the platform's own notion of
line separator as defined by the system property line.separator. Not all
platforms use the newline character ('\n') to terminate lines. Calling this
method to terminate each output line is therefore preferred to writing a
newline character directly."
Use a text editor for viewing files. NotePad is not a text editor. There are
many editors available. some are open source. I just "discovered" jEdit. I
think a more user-friendly and less powerful emacs.
Regards,
Frank