2014-12-01 19 views

cevap

11

Kullanım ResourceLoader ve ResourcePatternUtils:

class Foobar { 
    private ResourceLoader resourceLoader; 

    @Autowired 
    public Foobar(ResourceLoader resourceLoader) { 
     this.resourceLoader = resourceLoader; 
    } 

    Resource[] loadResources(String pattern) throws IOException { 
     return ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(pattern); 
    } 
} 

ve gibi kullanın:

Resource[] resources = foobar.loadResources("classpath*:../../dir/*.txt"); 
1

Eğer

@Autowired 
private ApplicationContext applicationContext; 
private Resource[] resources ; 

public loadResources() { 
    try { 
     resources = applicationContext.getResources("file:C:/XYZ/*_vru_*"); 
    } catch (IOException ex) { 
     ex.printStackTrace(); 
    } 
} 
Bahar

kullanıyorsanız
İlgili konular