mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
Issue #146: File API - File::writeAsText not in the API, remove
This commit is contained in:
parent
60be45b9d9
commit
66f7afbed2
@ -92,10 +92,6 @@ FileMgr.prototype.getFreeDiskSpace = function(successCallback, errorCallback) {
|
||||
return PhoneGap.exec(successCallback, errorCallback, "File", "getFreeDiskSpace", []);
|
||||
};
|
||||
|
||||
FileMgr.prototype.writeAsText = function(fileName, data, append, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "writeAsText", [fileName, data, append]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.write = function(fileName, data, position, successCallback, errorCallback) {
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "write", [fileName, data, position]);
|
||||
};
|
||||
|
@ -104,9 +104,6 @@ public class FileUtils extends Plugin {
|
||||
else if (action.equals("readAsDataURL")) {
|
||||
String s = this.readAsDataURL(args.getString(0));
|
||||
return new PluginResult(status, s);
|
||||
}
|
||||
else if (action.equals("writeAsText")) {
|
||||
this.writeAsText(args.getString(0), args.getString(1), args.getBoolean(2));
|
||||
}
|
||||
else if (action.equals("write")) {
|
||||
long fileSize = this.write(args.getString(0), args.getString(1), args.getInt(2));
|
||||
@ -914,26 +911,6 @@ public class FileUtils extends Plugin {
|
||||
return map.getMimeTypeFromExtension(map.getFileExtensionFromUrl(filename));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write contents of file.
|
||||
*
|
||||
* @param filename The name of the file.
|
||||
* @param data The contents of the file.
|
||||
* @param append T=append, F=overwrite
|
||||
* @throws FileNotFoundException, IOException
|
||||
*/
|
||||
public void writeAsText(String filename, String data, boolean append) throws FileNotFoundException, IOException {
|
||||
String FilePath= filename;
|
||||
byte [] rawData = data.getBytes();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(rawData);
|
||||
FileOutputStream out= new FileOutputStream(FilePath, append);
|
||||
byte buff[] = new byte[rawData.length];
|
||||
in.read(buff, 0, buff.length);
|
||||
out.write(buff, 0, rawData.length);
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write contents of file.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user