public String test() {
		String root = ServletActionContext.getServletContext().getRealPath("/");
		String root1 = "te/st/21.jpg";
		File cat=new File(root);
		
		System.out.println("root="+root);
		System.out.println("parent="+cat.getParent());
		System.out.println("="+root1.substring(root1.indexOf('s')));
		return "success";
	}

  • 测试结果:
    Java String 字符串截取和获取文件的上级目录

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-11-27
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-02
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案