From e0cdf708008cc29b67d237c2ca0e513398fe927e Mon Sep 17 00:00:00 2001 From: ZhuWanShan Date: Fri, 17 Mar 2017 15:47:58 +0800 Subject: [PATCH] Support http|https Resources --- text.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/text.js b/text.js index b8370d6..391ebf7 100644 --- a/text.js +++ b/text.js @@ -328,11 +328,20 @@ define(['module'], function (module) { typeof Packages !== 'undefined' && typeof java !== 'undefined')) { //Why Java, why is this so awkward? text.get = function (url, callback) { + + //Support HTTP Resources + var inputStream = undefined; + if(url.toLowerCase().startsWith("http://") + ||url.toLowerCase().startsWith("https:")){ + inputStream = new java.net.URL(url).openStream(); + }else{ + inputStream = new java.io.FileInputStream(url); + } + var stringBuffer, line, encoding = "utf-8", - file = new java.io.File(url), lineSeparator = java.lang.System.getProperty("line.separator"), - input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)), + input = new java.io.BufferedReader(new java.io.InputStreamReader(inputStream, encoding)), content = ''; try { stringBuffer = new java.lang.StringBuffer();