相關(guān)資訊
本類常用軟件
-
福建農(nóng)村信用社手機(jī)銀行客戶端下載下載量:584204
-
Windows優(yōu)化大師下載量:416898
-
90美女秀(視頻聊天軟件)下載量:366961
-
廣西農(nóng)村信用社手機(jī)銀行客戶端下載下載量:365699
-
快播手機(jī)版下載量:325855
我和一向?qū)Τ绦虮容^感興趣,但因為很多原因沒有能堅持下來,不過也收集了一些有用的代碼吧.
得到當(dāng)前路徑
File f = new File(“.”);
String absolutePath = f.getAbsolutePath();
System.out.println(absolutePath);
1.路徑中空格:
String pathtem=null;
URL ut=Thread.currentThread().getContextClassLoader().getResource(“”);
pathtem=ut.toString();
pathtem=pathtem.replace(“%20″, ” “);//去掉空格
pathtem=pathtem.substring(6,pathtem.length());//去掉”file:/”
返回:
d:/apache/webapp/Ev/WEB-INF/classes/
struts中得到路徑
String rootuploadpath = this.getServlet().getServletContext().getRealPath(“/”);
2.生成jar包后
String pathtem=null;
URL ut=Csssb_se.class.getResource(“”);
pathtem=ut.toString();
pathtem=pathtem.replace(“%20″, ” “);
pathtem=pathtem.substring(0,pathtem.indexOf(projectname));
pathtem=pathtem.replace(“file:///”,”");
pathtem=pathtem.replace(“file:/”,”");
pathtem=pathtem.replace(“jar:”,”");
3.生成war包后,Tomcat
String Dirpath = null;
String Project_name = “TranData”;
URL ut = Thread.currentThread().getContextClassLoader().getResource(“”);
Dirpath = ut.toString();
Dirpath = Dirpath.replace(“%20″, ” “);
Dirpath = Dirpath.substring(6, Dirpath.length());
int project_name_index = Dirpath.indexOf(Project_name);
Dirpath = Dirpath.substring(0, project_name_index
+ Project_name.length() + 1);
String xmlfilepath = Dirpath + “s.xml”;