From 7c1eb7da9b1d00aec92ffd153b5d561f4abde266 Mon Sep 17 00:00:00 2001 From: Fil Maj Date: Fri, 17 Feb 2012 10:55:04 -0800 Subject: [PATCH] trim file:// URI from uri->path conversion method --- framework/src/org/apache/cordova/FileUtils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java index c1489679..51fc4ab3 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); } }