1、删除文件

/**
* delete file
* 删除文件
* @param fileName
* @return
*/
private boolean deleteDir(String fileName)
{
boolean flag = false;
File file = new File(fileName);
if(file.exists()){
flag = delFile(file);
} return flag;
} /**
* delete file
* 删除文件
* @param fileName
* @return
*/
private boolean delFile(File file) {
if (!file.exists()) {
return false;
} if (file.isDirectory()) {
File[] files = file.listFiles();
for (File f : files) {
delFile(f);
}
}
return file.delete();
}

  2、获取项目根路径

/**
* 获取路径
* @return
*/
public String getWebRoot()
{
String realUrl = getClass().getProtectionDomain().getCodeSource()
.getLocation().getPath(); String newUrl = ""; if (realUrl.contains("/WEB-INF/"))
{
newUrl = realUrl.substring(, realUrl.lastIndexOf("WEB-INF/"));
} realUrl = newUrl.replace("%20", " ");//此路径不兼容jboss return realUrl;
}

  

最新文章

  1. 用powershell批量新增user profile
  2. LeetCode:Find the Difference_389
  3. jQuery的事件委托实例分析
  4. ASP.NET MVC Web API 学习笔记---第一个Web API程序
  5. 转:纠结的Shim
  6. Android线程管理(三)——Thread类的内部原理、休眠及唤醒
  7. redmine一键安装
  8. 二模08day1解题报告
  9. HA集群heartbeat配置--Nginx
  10. Database Design Guidelines
  11. Python01(linux基础)
  12. mssql 怎么配置指定的表 不允许删除数据?
  13. 【演变】Ajax(AjAj)到WebSocket
  14. Unity调试模式设置辅助线是否可见
  15. [ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.5.0-rc1:compile (default) on project zeus-web: Command 解决
  16. 向eclipse的JavaWeb项目中导入jar包
  17. 使用ant优化android项目编译速度,提高工作效率
  18. Prime Ring Problem dfs
  19. js往div里添加table
  20. PlSQL Oracle 中的 对应 SQL server 中的 IsNull(Expr1,Expr2)

热门文章

  1. C# DictionaryHelper
  2. [转] Java 使用Try-with-resources自动关闭资源
  3. 给新人看的 JavaScript的继承
  4. 字典树+map
  5. MyBatis 源码解析SqlSession.getConnection(Connection异常:关闭或者不在Mybatis事务)
  6. gitlab 日常运维命令
  7. PIE SDK文本元素的绘制
  8. AutoFac之 Named and Keyed 方式注入
  9. (转)用shell脚本实现杨辉三角的4个实例!
  10. 【JAVA】重载和重写的区别