本文整理了Java中org.mozilla.javascript.tools.shell.Global.readUrl()
方法的一些代码示例,展示了Global.readUrl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Global.readUrl()
方法的具体详情如下:
包路径:org.mozilla.javascript.tools.shell.Global
类名称:Global
方法名:readUrl
[英]The readUrl opens connection to the given URL, read all its data and converts them to a string using the specified character coding or default character coding if explicit coding argument is not given.
Usage:
readUrl(url)
readUrl(url, charCoding)
The first form converts file's context to string using the default charCoding.
[中]readUrl打开与给定URL的连接,读取其所有数据,并使用指定的字符编码或默认字符编码(如果未提供显式编码参数)将其转换为字符串。
用法:
readUrl(url)
readUrl(url, charCoding)
第一个表单使用默认字符编码将文件的上下文转换为字符串。
代码示例来源:origin: com.github.tntim96/rhino
/**
* The readFile reads the given file content and convert it to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readFile(filePath)
* readFile(filePath, charCoding)
* </pre>
* The first form converts file's context to string using the default
* character coding.
*/
public static Object readFile(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readFile.bad.args");
}
String path = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(path, charCoding, true);
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* The readUrl opens connection to the given URL, read all its data
* and converts them to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readUrl(url)
* readUrl(url, charCoding)
* </pre>
* The first form converts file's context to string using the default
* charCoding.
*/
public static Object readUrl(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readUrl.bad.args");
}
String url = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(url, charCoding, false);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* The readFile reads the given file content and convert it to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readFile(filePath)
* readFile(filePath, charCoding)
* </pre>
* The first form converts file's context to string using the default
* character coding.
*/
public static Object readFile(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readFile.bad.args");
}
String path = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(path, charCoding, true);
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
/**
* The readFile reads the given file content and convert it to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readFile(filePath)
* readFile(filePath, charCoding)
* </pre>
* The first form converts file's context to string using the default
* character coding.
*/
public static Object readFile(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readFile.bad.args");
}
String path = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(path, charCoding, true);
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
/**
* The readUrl opens connection to the given URL, read all its data
* and converts them to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readUrl(url)
* readUrl(url, charCoding)
* </pre>
* The first form converts file's context to string using the default
* charCoding.
*/
public static Object readUrl(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readUrl.bad.args");
}
String url = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(url, charCoding, false);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* The readUrl opens connection to the given URL, read all its data
* and converts them to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readUrl(url)
* readUrl(url, charCoding)
* </pre>
* The first form converts file's context to string using the default
* charCoding.
*/
public static Object readUrl(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readUrl.bad.args");
}
String url = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(url, charCoding, false);
}
内容来源于网络,如有侵权,请联系作者删除!