This repository was archived by the owner on Aug 9, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMain.hx
More file actions
41 lines (29 loc) · 1.18 KB
/
Main.hx
File metadata and controls
41 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package;
import sys.io.File;
// http://api.haxe.org/sys/io/File.html
// http://old.haxe.org/forum/thread/4271
// http://old.haxe.org/doc/sys/io/filesystem
class Main {
public static function main () {
//----------------------------------------------------------------------
trace('--- Write to text file ---');
File.saveContent("test.txt", "123 qwe 321");
var fileContent = File.getContent("test.txt");
trace("Original content: " + fileContent);
//----------------------------------------------------------------------
trace('--- Change text file ---');
fileContent = File.getContent("test.txt");
fileContent = StringTools.replace(fileContent, "qwe", "AND");
File.saveContent("test.txt", fileContent);
fileContent = File.getContent("test.txt");
trace("Changed content: " + fileContent);
//----------------------------------------------------------------------
trace('--- Append data to end of text file ---');
var fileStream = File.append("test.txt");
fileStream.writeString("\r\n");
fileStream.writeString("additional text");
fileStream.close();
fileContent = File.getContent("test.txt");
trace("Added content: " + fileContent);
}
}