Note: With Spring I haven't found out a way to do it...
ClassPathResource, FileSystemResource and UrlResource were big failures....
Filestructure:
- micharg/Caller.java
- foo.xml
Code:
package micharg;
public class Caller {
...
InputStream in = getClass().getResourceAsStream("/foo.xml");
BufferedReader input = new BufferedReader(new InputStreamReader(in));
StringBuilder xml = new StringBuilder();
String line;
String NEW_LINE = System.getProperty("line.separator");
while ((line = input.readLine()) != null)
xml.append(line + NEW_LINE);
input.close();
System.out.println(xml.toString());
...
References
StackOverflow
No comments:
Post a Comment