1、java.io.File idea下都读取不到,我们就不试jar包了。(下同) 2、java.lang.ClassLoader#getSystemResourceAsStream 3、class.getClassLoader().getResourceAsStream 4、org.springframework.core.io.FileSystemResource 5、org.springframework.core.io.FileSystemResourceLoader 综上,第3,第5种方式都行;为操作方...
D:\>java -jar D:\testDemo-1.0-SNAPSHOT.jar Exception in thread "main" java.io.FileNotFoundException: file:\D:\testDemo-1.0-SNAPSHOT.jar!\test.txt (文件名、目录名或卷标语法不正确。) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at j...
String params = getClass().getClassLoader().getResource("system-config.properties").getPath().replace("%20", " "); 1.
String params = getClass().getClassLoader().getResource("system-config.properties").getPath().replace("%20", " "); 1.
java 获取src下包的文件的路径,getClass().getClassLoader().getResource("/sy/config/sheetMonitor-config.xml").getPath().replace("%20","")