From 66f7afbed2e88e9b9c8e756c0ace76a30c5e78c7 Mon Sep 17 00:00:00 2001 From: macdonst Date: Tue, 12 Jul 2011 11:07:40 +0800 Subject: [PATCH] Issue #146: File API - File::writeAsText not in the API, remove --- framework/assets/js/file.js | 4 ---- framework/src/com/phonegap/FileUtils.java | 23 ----------------------- 2 files changed, 27 deletions(-) diff --git a/framework/assets/js/file.js b/framework/assets/js/file.js index 11229b35..6332bc1f 100755 --- a/framework/assets/js/file.js +++ b/framework/assets/js/file.js @@ -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]); }; diff --git a/framework/src/com/phonegap/FileUtils.java b/framework/src/com/phonegap/FileUtils.java index 08ff7cce..c707f293 100755 --- a/framework/src/com/phonegap/FileUtils.java +++ b/framework/src/com/phonegap/FileUtils.java @@ -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. *