Resource[] resources = (Resource[]) resolver.getResources("classpath*:commonscripts/*.sh");
for (Resource re : resources) {
System.out.println(convertStreamToString(re.getInputStream()));
}
private static String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
网友评论