@@ -119,7 +119,8 @@ public static Object removeCachedFileData(String path) {
119119 */
120120 @ SuppressWarnings ("unused" )
121121 private static Object getFileContents (Object uriOrJSFile , boolean asBytes ) {
122- if (uriOrJSFile instanceof File ) {
122+ boolean isFile = (uriOrJSFile instanceof File );
123+ if (isFile ) {
123124 byte [] bytes = /** @j2sNative uriOrJSFile.秘bytes || */
124125 null ;
125126 if (bytes != null )
@@ -142,15 +143,18 @@ private static Object getFileContents(Object uriOrJSFile, boolean asBytes) {
142143 }
143144 if (data == null && !uri .startsWith ("./" )) {
144145 // Java applications may use "./" here
145- try {
146- BufferedInputStream stream = (BufferedInputStream ) new URL (uri ).getContent ();
147- data = (asBytes ? Rdr .getStreamAsBytes (stream , null ) : Rdr .streamToUTF8String (stream ));
148- } catch (Exception e ) {
149- // bypasses AjaxURLConnection
150- data = J2S .getFileData (uri , null , false , asBytes );
151- if (data == null )
152- removeCachedFileData (uri );
146+ if (!isFile ) {
147+ try {
148+ BufferedInputStream stream = (BufferedInputStream ) new URL (uri ).getContent ();
149+ return (asBytes ? Rdr .getStreamAsBytes (stream , null ) : Rdr .streamToUTF8String (stream ));
150+ } catch (Exception e ) {
151+ }
153152 }
153+ // bypasses AjaxURLConnection
154+ data = J2S .getFileData (uri , null , false , asBytes );
155+ if (data == null )
156+ removeCachedFileData (uri );
157+
154158 }
155159 return data ;
156160 }
@@ -596,6 +600,14 @@ public static BufferedInputStream getURLInputStream(URL url, boolean andDelete)
596600 return null ;
597601 }
598602
603+ /**
604+ * Display the web page in the give target, such as "_blank"
605+ */
606+ @ Override
607+ public void displayURL (String url , String target ) {
608+ showWebPage ((URL )(Object )url , target );
609+ }
610+
599611 public static void showWebPage (URL url , Object target ) {
600612 /**
601613 * @j2sNative
@@ -604,6 +616,8 @@ public static void showWebPage(URL url, Object target) {
604616 * window.open(url.toString());
605617 */
606618 }
619+
620+
607621
608622 /**
609623 * important warnings for TODO list
0 commit comments