易截截图软件、单文件、免安装、纯绿色、仅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时区解决方案

 tomcat启动web服务的时候总是会有8小时的时差,
琢磨了好久,最简单的办法就是
找到文件夹jdk1.6.0_07\jre\lib\zi\Etc
这里边都是一些时区文件GTM+1,GTM+2,GTM+3....
备份一份Etc
拷贝N份GTM+8文件(中国的时区是GTM+8)
把GMT+8文件名改成GTM+1,GTM+2,GTM+3....
覆盖掉原来的Etc里边的文件
重启tomcat问题解决 ......

Java之static学习

对于学习static我们先来看两个例子:
//Example 1 Tst.java,no main() method
package com.blogchina.qb2049;
public class Tst
{
static { System.out.println("111111"); }
}
运行结果为: 111111
Exception in thread "main" java.lang.NoSuchMethodError: main
同样的道理看第二 ......

java中关于时间日期操作的常用函数

1.计算某一月份的最大天数
Calendar time=Calendar.getInstance();
time.clear();
time.set(Calendar.YEAR,year);
time.set(Calendar.MONTH,i-1);//注意,Calendar对象默认一月为0            
int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);//本月份的天数 ......

Serializable java序列化

Bean Serializable Interface 的接口让BEAN可以串行化,将其变成一个可保存为以后使用的二进制流。当一个BEAN被系列化到磁盘上或者其他任何地方,其状态被保存起来,其中的属性值也不会改变。在BEAN的规范中,JSP并没有要求BEAN实现Serializable接口。但是,如果您希望自己控制您所创建的组件的serialization进程,或者您想 ......

Oracle 与在Java中的链接

转帖处:http://dong-java.javaeye.com/blog/375150 
1。推荐使用Oralce比较新的10.2.0.3 JDBC Drivers。这个版本对比9.2的最大的好处是DriverManager.setLoginTimeout函数是起作用的。设置了这个参数,在恶劣的网络环境中就不会有连接数据库的函数长时间不返回的情况。
2。JDBC Developer!ˉs Guide and Refer ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号