您的位置:首页 > 编程语言 > Java开发

读取spring配置文件的方法(spring读取资源文件)

2014-02-24 09:53 1546 查看
public void test() throws IOException {  Resource resource = ApplicationContextFactory.getApplicationContext().getResource("classpath:com/springdemo/resource/test.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 spring 配置文件