123456789101112131415161718192021222324 |
- package com.lovecoding.resources;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- import org.springframework.core.io.Resource;
- import java.io.IOException;
- import java.io.InputStream;
- public class ResourceLoaderDemo {
- public static void main(String[] args) {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
- Resource resource = context.getResource("classpathdemo.properties");
- InputStream inputStream = null;
- try {
- inputStream = resource.getInputStream();
- byte[] n = new byte[1024];
- while ( inputStream.read(n) != -1 ) {
- System.out.println( new String(n) );
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
|