Created
April 18, 2014 15:59
-
-
Save cneud/11051443 to your computer and use it in GitHub Desktop.
Beanshell for counting chars in Taverna
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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