reading content from a jar from inside an Ant Javascript script task

Here's another handy little snippet for reading the content from a jar file while inside a javascript Ant <script> tag (in this example, reading the property file that is inside the ant-contrib jar@/net/sf/antcontrib/antcontrib.properties):

<script language="javascript">
    <![CDATA[
    importPackage(Packages.java.io);
    var antprops = project.getClass().getResource('/net/sf/antcontrib/antcontrib.properties');
    var inis = antprops.openStream();
    var br = new BufferedReader(new InputStreamReader(inis));
    while (null != (line = br.readLine())) {
     print(line);
    }
    ]]>

</script>

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.3.000. Contact Blog Owner