I'm trying to write a custom scriptselector, and to do so I need to read the contents of each file.
Is there a way to use java, and not javascript, as the language of a scriptselector? If not, is there a way, silly as it sounds, to read the File object?
<scriptselector language="javascript">
f = self.getFile();
println(f);
//how to read the File?
self.setSelected(true);
</scriptselector>
Apache Ant is a software tool for automating software build processes which originated from the Apache Tomcat project in early 2000 as a replacement for the Make build tool of Unix. It is similar to Make, but is implemented using the Java language and requires the Java platform.
Ant is a Java-based build tool created as part of the Apache open-source project. You can think of it as a Java version of make. Ant scripts have a structure and are written in XML. Similar to make, Ant targets can depend on other targets. For example, Ant is used in the context of plug-in development in the build.
Here's how. Something along the lines of:
<scriptselector language="javascript">
importPackage(java.io);
importPackage(org.apache.tools.ant.util);
fileUtils = FileUtils.getFileUtils();
f = self.getFile();
println(f);
if( f.getAbsolutePath().endsWith(".xyz") ){
fis = new FileInputStream(f.getAbsolutePath());
isr = new InputStreamReader(fis);
println('reading it!');
fileContents = fileUtils.readFully(isr);
println(fileContents);
self.setSelected(true);
}
</scriptselector>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With