Flex - writeUTF() vs writeUTFBytes()
I am using FileStream.writeUTF() to write out an XML file, and I noticed that the file is being prefixed by strange characters, which is messing up my XML.
var file:File = File.desktopDirectory.resolvePath(FILENAME); var fileStream:FileStream = new FileStream(); fileStream.open(file, FileMode.WRITE); fileStream.writeUTF(data); // file now has data prefixed by strange characters fileStream.close();
It turns out that this is by design, as the writeUTF() function prefixes the file with the length of the file. God knows why it does that, but the solution is to use writeUTFBytes() instead - does the same thing without prefixing the data with the length. Does anyone know why the writeUTF() function writes out the length?
