时间的法外狂徒

导航

随笔分类 -  java 路径问题

maven项目读取resources下文件
摘要:resources文件夹对系统来说属于动态目录,随着编译后文件移动。当有些方法需要找到绝对路径时,需要通过读取resources来形成它的绝对路径。 1、读取成file import java.io.File; import java.net.URL; URL url = WcsWindow.cla 阅读全文

posted @ 2021-04-15 17:11 抄手砚 阅读(912) 评论(0) 推荐(0)

java读取Properties文件的方法
摘要:resource.properties的内容: com.tsinkai.ettp.name=imooc com.tsinkai.ettp.website=www.imooc.com com.tsinkai.ettp.language=java 1、使用java.util.Properties的loa 阅读全文

posted @ 2019-10-15 17:26 抄手砚 阅读(1663) 评论(0) 推荐(0)

getResourceAsStream的路径问题
摘要:1、Class类的getResourceAsStream this.getClass().getResourceAsStream("/resource.properties"); 参数以/开头,读取ClassPath目录下的文件;不以/开头,读取本包下的文件。 2、ClassLoader类的getR 阅读全文

posted @ 2019-10-15 16:51 抄手砚 阅读(5469) 评论(0) 推荐(0)

java(包括springboot)读取resources下文件方式
摘要:1、使用项目内路径读取,该路径只在开发工具中显示,类似:src/main/resources/resource.properties。只能在开发工具中使用,部署之后无法读取。(不通用) File file = new File("src/main/resources/resource.propert 阅读全文

posted @ 2019-10-15 14:53 抄手砚 阅读(97095) 评论(5) 推荐(17)

java项目路径总结,java.io.File支持的路放方式
摘要:1、直接输入路径 已maven项目为例,直接输入路径的4种方式,即是File类支持的方式: /** * FileOutpurStream以字节数组方式写入文件 * @throws IOException */ @Test public void testFileOutputStramBytes() 阅读全文

posted @ 2019-10-10 16:48 抄手砚 阅读(476) 评论(0) 推荐(0)