merge
This commit is contained in:
@@ -4,6 +4,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 说明: java.io.File File的每一个实例可以表示文件系统中的一个文件或目录 使用file可以:
|
||||
@@ -62,7 +63,10 @@ public class FileDemo {
|
||||
* java resources 编译后在WEB-INF/classes下 同级
|
||||
*/
|
||||
String tomcatHome = System.getProperty("catalina.home");//服务器tomcat路径
|
||||
ClassPathResource pic = new ClassPathResource("conf");//获取classes下conf文件夹路径
|
||||
ClassPathResource pic = new ClassPathResource("file");//获取classes下file文件夹路径
|
||||
String absolutePath = pic.getFile().getAbsolutePath();
|
||||
//配置文件
|
||||
String filePath = IODemo.class.getResource("/redis.properties").getPath();
|
||||
InputStream in = IODemo.class.getResourceAsStream("/redis.properties");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.xwbing.demo;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
@@ -96,14 +94,5 @@ public class IODemo {
|
||||
PrintWriter pw1 = new PrintWriter(osw, true);///////当第一个参数为流,可以使用第二个参数来指定是否自动flush
|
||||
pw1.println("......");
|
||||
pw1.close();
|
||||
|
||||
|
||||
/**
|
||||
* 读取文件
|
||||
*/
|
||||
String filePath = IODemo.class.getResource("/redis.properties").getPath();
|
||||
InputStream in = IODemo.class.getResourceAsStream("/redis.properties");
|
||||
ClassPathResource pic = new ClassPathResource("file");
|
||||
String absolutePath = pic.getFile().getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user