Skip to content

Instantly share code, notes, and snippets.

@cneud
Created April 18, 2014 15:59
Show Gist options
  • Save cneud/11051443 to your computer and use it in GitHub Desktop.
Save cneud/11051443 to your computer and use it in GitHub Desktop.
Beanshell for counting chars in Taverna
BufferedReader getReader (String fileUrl) throws IOException {
InputStreamReader reader;
try {
reader = new FileReader(fileUrl);
}
catch (FileNotFoundException e) {
// try a real URL instead
URL url = new URL(fileUrl);
reader = new InputStreamReader (url.openStream());
}
return new BufferedReader(reader);
}
StringBuffer sb = new StringBuffer(4000);
BufferedReader in = getReader(fileurl);
String str;
String lineEnding = System.getProperty("line.separator");
while ((str = in.readLine()) != null) {
sb.append(str);
}
in.close();
filecontents = sb.length();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment