1 17 package org.apache.servicemix.jbi.jaxp; 18 19 import org.springframework.core.io.Resource; 20 21 import javax.xml.transform.stream.StreamSource ; 22 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 import java.io.InputStreamReader ; 26 import java.io.Reader ; 27 28 34 public class ResourceSource extends StreamSource { 35 36 private final Resource resource; 37 38 public ResourceSource(Resource resource) { 39 this.resource = resource; 40 } 41 42 public InputStream getInputStream() { 43 try { 44 return resource.getInputStream(); 45 } 46 catch (IOException e) { 47 throw new RuntimeException ("Failed to open resource: " + resource + ". Reason: " + e, e); 48 } 49 } 50 51 public Reader getReader() { 52 return new InputStreamReader (getInputStream()); 53 } 54 55 56 } 57 | Popular Tags |