You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bc...@apache.org on 2012/02/17 23:58:02 UTC
[2/16] android commit: trim file:// URI from uri->path conversion
method
trim file:// URI from uri->path conversion method
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/7c1eb7da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/7c1eb7da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/7c1eb7da
Branch: refs/heads/master
Commit: 7c1eb7da9b1d00aec92ffd153b5d561f4abde266
Parents: d87ee71
Author: Fil Maj <fi...@nitobi.com>
Authored: Fri Feb 17 10:55:04 2012 -0800
Committer: Fil Maj <fi...@nitobi.com>
Committed: Fri Feb 17 10:55:04 2012 -0800
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileUtils.java | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/7c1eb7da/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index c148967..51fc4ab 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -914,8 +914,8 @@ public class FileUtils extends Plugin {
*/
public String readAsText(String filename, String encoding) throws FileNotFoundException, IOException {
byte[] bytes = new byte[1000];
- BufferedInputStream bis = new BufferedInputStream(getPathFromUri(filename), 1024);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ BufferedInputStream bis = new BufferedInputStream(getPathFromUri(filename), 1024);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
int numRead = 0;
while ((numRead = bis.read(bytes, 0, 1000)) >= 0) {
bos.write(bytes, 0, numRead);
@@ -1025,6 +1025,9 @@ public class FileUtils extends Plugin {
return ctx.getContentResolver().openInputStream(uri);
}
else {
+ if (path.startsWith("file://")) {
+ path = path.substring(7);
+ }
return new FileInputStream(path);
}
}