本文整理汇总了Java中org.mozilla.javascript.tools.SourceReader.readFileOrUrl方法的典型用法代码示例。如果您正苦于以下问题:Java SourceReader.readFileOrUrl方法的具体用法?Java SourceReader.readFileOrUrl怎么用?Java SourceReader.readFileOrUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.tools.SourceReader
的用法示例。
在下文中一共展示了SourceReader.readFileOrUrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readSource
import org.mozilla.javascript.tools.SourceReader; //导入方法依赖的package包/类
private String readSource(File f)
{
String absPath = f.getAbsolutePath();
if (!f.isFile()) {
addError("msg.jsfile.not.found", absPath);
return null;
}
try {
return (String)SourceReader.readFileOrUrl(absPath, true,
characterEncoding);
} catch (FileNotFoundException ex) {
addError("msg.couldnt.open", absPath);
} catch (IOException ioe) {
addFormatedError(ioe.toString());
}
return null;
}
示例2: readSource
import org.mozilla.javascript.tools.SourceReader; //导入方法依赖的package包/类
private String readSource(File f)
{
String absPath = f.getAbsolutePath();
if (!f.isFile()) {
addError("msg.jsfile.not.found", absPath);
return null;
}
try {
return (String)SourceReader.readFileOrUrl(absPath, true,
characterEncoding);
} catch (FileNotFoundException ex) {
addError("msg.couldnt.open", absPath);
} catch (IOException ioe) {
addFormatedError(ioe.toString());
}
return null;
}
示例3: readFileOrUrl
import org.mozilla.javascript.tools.SourceReader; //导入方法依赖的package包/类
/**
* Read file or url specified by <tt>path</tt>.
* @return file or url content as <tt>byte[]</tt> or as <tt>String</tt> if
* <tt>convertToString</tt> is true.
*/
private static Object readFileOrUrl(String path, boolean convertToString)
{
try {
return SourceReader.readFileOrUrl(path, convertToString,
shellContextFactory.getCharacterEncoding());
} catch (IOException ex) {
Context.reportError(ToolErrorReporter.getMessage(
"msg.couldnt.read.source", path, ex.getMessage()));
return null;
}
}
示例4: test262SuiteValues
import org.mozilla.javascript.tools.SourceReader; //导入方法依赖的package包/类
@Parameters(name = "js={0}, opt={3}, strict={4}")
public static Collection<Object[]> test262SuiteValues() throws IOException {
List<Object[]> result = new ArrayList<Object[]>();
List<File> tests = getTestFiles();
for (File jsTest : tests) {
String jsFileStr = (String) SourceReader.readFileOrUrl(jsTest.getPath(), true, "UTF-8");
List<String> harnessFiles = new ArrayList<String>();
harnessFiles.add("sta.js");
harnessFiles.add("assert.js");
Map header = (Map) YAML.load(jsFileStr.substring(jsFileStr.indexOf("/*---") + 5, jsFileStr.lastIndexOf("---*/")));
if (header.containsKey("includes")) {
harnessFiles.addAll((Collection)header.get("includes"));
}
EcmaErrorType errorType = EcmaErrorType._valueOf((String)header.get("negative"));
List<String> flags = header.containsKey("flags") ? (List<String>) header.get("flags") : Collections.EMPTY_LIST;
for (int optLevel : OPT_LEVELS) {
if (!flags.contains("onlyStrict")) {
result.add(new Object[]{jsTest.getPath(), jsFileStr, harnessFiles, optLevel, false, errorType});
}
if (!flags.contains("noStrict")) {
result.add(new Object[]{jsTest.getPath(), jsFileStr, harnessFiles, optLevel, true, errorType});
}
}
}
return result;
}
示例5: readFileOrUrl
import org.mozilla.javascript.tools.SourceReader; //导入方法依赖的package包/类
/**
* Read file or url specified by <tt>path</tt>.
* @return file or url content as <tt>byte[]</tt> or as <tt>String</tt> if
* <tt>convertToString</tt> is true.
*/
private static Object readFileOrUrl(String path, boolean convertToString)
throws IOException
{
return SourceReader.readFileOrUrl(path, convertToString,
shellContextFactory.getCharacterEncoding());
}
示例6: readFileOrUrl
import org.mozilla.javascript.tools.SourceReader; //导入方法依赖的package包/类
/**
* Read file or url specified by <tt>path</tt>.
*
* @return file or url content as <tt>byte[]</tt> or as <tt>String</tt> if
* <tt>convertToString</tt> is true.
*/
private static Object readFileOrUrl(String path, boolean convertToString)
throws IOException {
return SourceReader.readFileOrUrl(path, convertToString,
shellContextFactory.getCharacterEncoding());
}