「Spring」設定ファイルを読み込む方法

Javaコード

public void readprop() throws IOException
{
Resource resource = ApplicationContextFactory.getApplicationContext().getResource(“classpath:com/cftspring/resource/tdemoconfig.txt");

File file = resource.getFile();
byte[] buffer =new byte[(int) file.length()];
FileInputStream is =new FileInputStream(file);

is.read(buffer, 0, buffer.length);

is.close();
String str = new String(buffer);
System.out.println(str);

}

Java

Posted by arkgame