언어 설정

Menu
Sites
Language
Unable to use FileStream.writeBytes() method

I have been trying for half a day to write binary data to a file using the FileStream.writeBytes() method. According to the documentation, it should accept an argument like this:

writeBytes(octet[] byteData)

But, as far as I know, Javascript does not have a data type "octet[]". I tried using a normal array and also things like ArrayBuffer, but everytime I get a message in the console:

TypeMismatchError: Type mismatch error

Please advise.

Kind regards,

Rob

Responses

3 댓글
Andrew Gudz

This write "ABCDE" to file for me.

try {
var myfs = null;
tizen.filesystem.resolve(
    'file:///opt/usr/media/test.txt',
	function(dir){
		dir.openStream(
			"w",
			function(fs){
				myfs = fs;
				fs.writeBytes([65,66,67,68,69]);
			}, function(e){
				console.log("Error " + e.message);
			}, "UTF-8"
		);

	}, function(e) {
		console.log("Error" + e.message);
	}, "w"
);
} catch(e) {
	console.log(e.name + " " + e.message);
}

 

Rob Guinness

Thanks, but what if I need to write 32-bit floats?

AVSukhov

Hello,

You can get octet[] only from readBytes()