直接读取方式:
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); }public void test() throws IOException