Sunday, June 1, 2008

Code snippets:File I/O

Writing to a file

←Older revision Revision as of 00:39, 20 March 2008 Line 290: Line 290: // use 0x02 | 0x10 to open file for appending. // use 0x02 | 0x10 to open file for appending. -foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0); // write, create, truncate+foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0); -In a c file operation, we have no need to set file mode with or operation, directly using "r" or "w" usually.+// write, create, truncate  +// In a c file operation, we have no need to set file mode with or operation,  +// directly using "r" or "w" usually. foStream.write(data, data.length); foStream.write(data, data.length); foStream.close(); foStream.close();