Considering the file is referred to as "temp", I'm not sure it's even needed. Peter's solutions assume you want to write a file
and get a byte[] array. If you don't need a file, and just want the byte[], then you can write it directly:
Note the OutputStreamWriter to convert between a Writer and an OutputStream. The one shown uses your platform default
character encoding, but you can use a different constructor to specify a different particular encoding if you like.
Incidentally, in this example the BufferedWriter doesn't really do anything useful; you might as well omit it and write with the OutputStream.
[ April 10, 2007: Message edited by: Jim Yingst ]