编程语言
首页 > 编程语言> > java项目资源路径总结

java项目资源路径总结

作者:互联网

1.File file = new File("\home\font\simhei.ttf");BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));

2.//D:\JAVA\WmsPdaApi_SUITE\src\main\webapp\String realPath = request.getSession().getServletContext().getRealPath("");

3.//file:/D:/JAVA/WmsPdaApi_SUITE/target/classes/com/vanew/api/wms/controller/URL resource = TestController.class.getResource("");

4.//file:/D:/JAVA/WmsPdaApi_SUITE/target/classes/URL resource = TestController.class.getResource("/");
5.//file:/D:/JAVA/WmsPdaApi_SUITE/target/classes/templates/application.propertiesURL resource = TestController.class.getResource("/templates/application.properties");

6.//file:/D:/JAVA/WmsPdaApi_SUITE/target/classes/URL resource1 = TestController.class.getClassLoader().getResource("");

7.//file:/D:/JAVA/WmsPdaApi_SUITE/target/classes/URL resource1 = TestController.class.getClassLoader().getResource(“application.properties”);

8.///D:/JAVA/WmsPdaApi_SUITE/target/classes/templates/application.propertiesURL resource1 = TestController.class.getClassLoader().getResource(“templates/application.properties”);

9.//null 默认从classpath中找文件(文件放在resources目录下),name不能带“/”,则会抛空指针URL resource1 = TestController.class.getClassLoader().getResource("/templates/application.properties");

10.//file:/D:/JAVA/WmsPdaApi_SUITE/target/classes/com/vanew/api/wms/controller/transfer/TincoWmsTransferController.classURL resource = TestController.class.getResource(“transfer/TincoWmsTransferController.class”);

标签:总结,getResource,java,WmsPdaApi,路径,TestController,file,SUITE,class
来源: https://blog.csdn.net/weixin_38610500/article/details/111773773