Write byte array to file with writeSync

nativescriptcore
ios
android

#1

encryptDecryptTheVideo(path: string) {
const currentAppFolder = fs.knownFolders.currentApp();
const videoFile = currentAppFolder.getFile(path);
this.folder = currentAppFolder.getFolder(this.folderName || “downloads”);
this.file = this.folder.getFile((this.fileName || “testFile”) + “.mp4”); // creates new video file
const fileData = videoFile.readSync((e) => { this.error = e; });
const fileText = base64js.fromByteArray(fileData);
const secretKey = “HelloWorld”;
const encryptedData = CryptoJS.AES.encrypt(fileText , secretKey);
const encryptedDataText = encryptedData.toString();
this.file.writeText(encryptedDataText)
.then((result) => {
this.file.readText()
.then((res) => {
this.successMessage = "Successfully saved in " + this.file.path;
this.writtenContent = res;
this.isItemVisible = true;
});
}).catch((err) => {
console.log(err);
});
const decryptedData = CryptoJS.AES.decrypt(encryptedData, secretKey);
const decryptedDataText = decryptedData.toString(CryptoJS.enc.Utf8);
const data = base64js.toByteArray(decryptedDataText);
this.newFVideoFile = this.folder.getFile((this.fileName || “output”) + “.mp4”);
this.newFVideoFile.writeSync(data, (err) => {
// console.log(err);
});

}

this is the main function, where it reads a downloaded video file,then encrypt it and write it into a new mp4 file named testFile.
again when it decrypts the encrypted data and try to write the bytearray into a new file after decryption, it gets error : java.lang.Exception: Failed resolving method write on class java.io.FileOutputStream
how can I solve this problem?