mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
trim file:// URI from uri->path conversion method
This commit is contained in:
parent
d87ee719a3
commit
7c1eb7da9b
@ -914,8 +914,8 @@ public class FileUtils extends Plugin {
|
|||||||
*/
|
*/
|
||||||
public String readAsText(String filename, String encoding) throws FileNotFoundException, IOException {
|
public String readAsText(String filename, String encoding) throws FileNotFoundException, IOException {
|
||||||
byte[] bytes = new byte[1000];
|
byte[] bytes = new byte[1000];
|
||||||
BufferedInputStream bis = new BufferedInputStream(getPathFromUri(filename), 1024);
|
BufferedInputStream bis = new BufferedInputStream(getPathFromUri(filename), 1024);
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
int numRead = 0;
|
int numRead = 0;
|
||||||
while ((numRead = bis.read(bytes, 0, 1000)) >= 0) {
|
while ((numRead = bis.read(bytes, 0, 1000)) >= 0) {
|
||||||
bos.write(bytes, 0, numRead);
|
bos.write(bytes, 0, numRead);
|
||||||
@ -1025,6 +1025,9 @@ public class FileUtils extends Plugin {
|
|||||||
return ctx.getContentResolver().openInputStream(uri);
|
return ctx.getContentResolver().openInputStream(uri);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (path.startsWith("file://")) {
|
||||||
|
path = path.substring(7);
|
||||||
|
}
|
||||||
return new FileInputStream(path);
|
return new FileInputStream(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user