How save text to file?

How to save text to file? I use writeToFile but get xml. How save to txt?

If using C you can use fopen() write(), etc.
If using c++ you can use ofstream.
Not sure about JSB if there’s an API for what you want? Should be a writeStringToFile method or something.

auto fs = FileUtils::getInstance();
auto docDir = fs->getWritablePath();   
auto filePath = docDir + "filename.txt";
auto data = std::string("this is a test\nanother line");
std::ofstream myfile;
myfile.open (filePath);
myfile << data << endl;

Thank you, but I use java script, and writeStringToFile does not work only writeToFile. But this method save to xml. Then I must write this myself.