Java String 字符串截取和獲取文件的上級目錄



  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";
	}

  • 測試結果:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM