易截截图软件、单文件、免安装、纯绿色、仅160KB

Java路径问题

JSP取路径:
//WEB站点根目录
request.getRealPath("/");
application.getRealPath("/");
//WEB站点JSP编译文件目录
String classFile = getClass().getName().substring(getClass().getName().lastIndexOf(".") + 1)+ ".java";
String path = getClass().getResource(classFileName);
JAVA取路径:
/**
* @author hujing
* @version 1.0
* @date 2009-9-9
* @class_displayName FilePath
*/
public class FilePath {
public static FilePath getInstance() {
return new FilePath();
}
public String getWebClassesPath() {
String path = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
return path;
}
/**
* get web rootPath
*/
public static String BL_getRootPath() {
//String path = FilePath.getInstance().getWebClassesPath();
String path = FilePath.getInstance().getRootPath();
path = path.substring(6);
int t = path.indexOf("WEB-INF");
path = path.substring(0, t);
return path;
}
public String getRootPath() {
String path = "";
try {
path = Thread.currentThread().getContextClassLoader().getResource("/").toString();
} catch (Exception e) {
e.printStackTrace();
}
return path;
}
}


相关文档:

java 调用命令 备份mysql数据库

 代码如下:
  1  String command  =   " cmd /c C:/Program Files/MySQL/MySQL Server 5.0/bin>mysqldump -h localhost -u root -p aijia > E:/aijia.dmp " ;
  2      try    {
  3     Process process& ......

Java 依赖注射规范(JSR

JCP SE/EE 执行委员会
正式接受了
JSR 330
—— Dependency Injection for Java。该规范于 今年 5 月 9 日
由 Google 的 Bob Lee 以及 SpringSource 的 Rod Johnson 作为规范领导提交给 JCP,现在已经正式发布,不得不感叹该规范标准化过程之快。在 最终投票结果中
,14 票通过,1 票未投,1 票反对。
J ......

Java虚拟机 和 java虚拟机下的进程

一、什么是Java虚拟机
     当你谈到Java虚拟机时,你可能是指:
     1、抽象的Java虚拟机规范
     2、一个具体的Java虚拟机实现
     3、一个运行的Java虚拟机实例
二、Java虚拟机的生命周期
     一个运行 ......

常见算法学习及其Java实现

package org.bupt.test;
import java.util.ArrayList;
class MyResource {
    ArrayList<Integer> arrList= new ArrayList<Integer>();
    public MyResource(ArrayList<Integer> arrList) {
        this.arrList = arrList;
&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号