本文整理了Java中org.javalite.common.Util.readFile()
方法的一些代码示例,展示了Util.readFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.readFile()
方法的具体详情如下:
包路径:org.javalite.common.Util
类名称:Util
方法名:readFile
[英]Reads contents of file fully and returns as string.
[中]完全读取文件内容并以字符串形式返回。
代码示例来源:origin: javalite/activejdbc
/**
* Reads contents of file fully and returns as string.
*
* @param fileName file name.
* @return contents of entire file.
*/
public static String readFile(String fileName) {
return readFile(fileName, "UTF-8");
}
代码示例来源:origin: com.github.tchoulihan/javalite-common
/**
* Reads contents of file fully and returns as string.
*
* @param fileName file name.
* @return contents of entire file.
*/
public static String readFile(String fileName) {
return readFile(fileName, "UTF-8");
}
代码示例来源:origin: org.javalite/javalite-common
/**
* Reads contents of file fully and returns as string.
*
* @param fileName file name.
* @return contents of entire file.
*/
public static String readFile(String fileName) {
return readFile(fileName, "UTF-8");
}
代码示例来源:origin: org.javalite/javalite-templator
private String loadTemplate(String templateName){
String slash = templateName.startsWith("/") ? "" : "/";
//for tests, load from location
if (templateLocation != null) {
return readFile(templateLocation + slash + templateName, "UTF-8");
}
//proceed to load from servlet context
String fullPath = "/WEB-INF/views" + slash + templateName;
// First try to open as plain file (to bypass servlet container resource caches).
String realPath = servletContext.getRealPath(fullPath);
try {
if (realPath != null) {
File file = new File(realPath);
if (!file.isFile()) {
throw new TemplateException(realPath + " is not a file");
}
if (file.canRead()) {
return readFile(realPath, "UTF-8");
}
}
} catch (SecurityException ignore) {}
try {
URL url = servletContext.getResource(fullPath);
return Util.read(url.openStream(), "UTF-8");
} catch (Exception e) {throw new TemplateException(e);}
}
内容来源于网络,如有侵权,请联系作者删除!