コード例 #1
0
 /**
  * Gets the contents of the given resource as a string.
  *
  * @param resource name (classpath) of the resource.
  * @return a String containing the contents of the stream
  * @exception IOException if an error occurs.
  */
 public static String resourceToString(final String resource) throws IOException {
   final InputStream str = Resources.getResourceAsStream(resource);
   if (str == null) {
     throw new RuntimeException("Unable to find resource:" + resource);
   }
   final String res = FileUtils.streamToString(str);
   str.close();
   return res;
 }