Get a resource from the GATE resources directory as a String. The resource name should be relative to resourcePath which is equal with gate/resources ; e.g. for a resource stored as gate/resources/jape/Test11.jape , this method should be passed the name jape/Test11.j
(String resourceName)
| 172 | * this method should be passed the name <TT>jape/Test11.jape</TT>. |
| 173 | */ |
| 174 | public static String getGateResourceAsString(String resourceName) |
| 175 | throws IOException { |
| 176 | InputStream resourceStream = getGateResourceAsStream(resourceName); |
| 177 | if (resourceStream == null) |
| 178 | throw new IOException("No such resource on classpath: " + resourceName); |
| 179 | try { |
| 180 | return IOUtils.toString(resourceStream,Charset.defaultCharset().name()); |
| 181 | } |
| 182 | finally { |
| 183 | resourceStream.close(); |
| 184 | } |
| 185 | } // getGateResourceAsString(String) |
| 186 | |
| 187 | /** |
| 188 | * Writes a temporary file into the default temporary directory, |