-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTextFile.as
More file actions
36 lines (34 loc) · 910 Bytes
/
TextFile.as
File metadata and controls
36 lines (34 loc) · 910 Bytes
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
package contents
{
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.utils.ByteArray;
public class TextFile
{
public static function load(fileTarget:File,skipChar:uint=0):String
{
if(fileTarget.exists)
{
var fileLoader:FileStream = new FileStream();
fileLoader.open(fileTarget,FileMode.READ);
//trace("2. debug time : "+getTimer());
fileLoader.position = skipChar ;
return fileLoader.readUTFBytes(fileLoader.bytesAvailable-skipChar);
}
else
{
trace(fileTarget.name+' file is not exists');
return null ;
}
}
public static function save(fileTarget:File,text:String):String
{
var textBytes:ByteArray = new ByteArray();
textBytes.writeUTFBytes(text);
var stat:String = FileManager.seveFile(fileTarget,textBytes);
trace("File save status : "+stat);
return stat ;
}
}
}