License:
BSD style: see license.txtVersion:
Mar 2004: Initial release Dec 2006: Outback release Nov 2008: relocated and simplifiedAuthor:
Kris, John Reimer, Anders F Bjorklund (Darwin patches), Chris Sauls (Win95 file support)
1 2 3 4 5 | // open a file for reading auto from = new File ("test.txt"); // stream directly to console Stdout.copy (from); |
1 2 3 4 5 6 7 8 9 | // open file for reading auto from = new File ("test.txt"); // open another for writing auto to = new File ("copy.txt", File.WriteCreate); // copy file and close to.copy.close; from.close; |
1 2 3 | auto file = new File ("test.txt"); auto content = file.load; file.close; |
1 | auto content = File.get ("test.txt"); |
1 2 3 4 5 6 7 8 9 | // open file for reading auto file = new File ("test.txt"); // create an array to house the entire file auto content = new char [file.length]; // read the file content. Return value is the number of bytes read auto bytes = file.read (content); file.close; |
1 2 3 4 5 | // open file for writing auto to = new File ("text.txt", File.WriteCreate); // write an array of content to it auto bytes = to.write (content); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // open a file for reading and writing auto file = new File ("random.bin", File.ReadWriteCreate); // write some data file.write ("testing"); // rewind to file start file.seek (0); // read data back again char[10] tmp; auto bytes = file.read (tmp); file.close; |
Return:
false in case of failure