文件读取
public void testReadFile() throws IOException {
File file = new File("src/main/resources/resource.properties");
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String data = null;
while((data = br.readLine()) != null) {
System.out.println(data);
}
br.close();
isr.close();
fis.close();
}
public String readToString(String fileName) {
String encoding = "UTF-8";
File file = new File(fileName);
Long filelength = file.length();
byte[] filecontent = new byte[filelength.intValue()];
try {
FileInputStream in = new FileInputStream(file);
in.read(filecontent);
return new String(filecontent, encoding);
} catch (Exception e) {
e.printStackTrace();
       return null;
} finally {
in.close;
}
}
springboot启动时控制台打印图案
不想看到图案:
public static void main(String[] args) {
SpringApplication application=new SpringApplication(Application.class);
/**
* OFF G关闭
* CLOSED 后台控制台输出,默认就是这种
* LOG 日志输出
*/
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
}
或者修改 application.yml
spring:
main:
banner-mode: off
如果我们想改动,那么只需要在src/main/recesources下新建一个banner.txt文件
Spring Boot启动项目的时候就会优先启动这个文件中的内容。