| 7 | import org.apache.commons.codec.digest.DigestUtils; |
| 8 | |
| 9 | public class Md5Function implements Function{ |
| 10 | |
| 11 | @Override |
| 12 | public String execute(String[] args) { |
| 13 | try { |
| 14 | String filePath = args[0]; |
| 15 | if (filePath.startsWith("http")) { |
| 16 | return DigestUtils.md5Hex(new URL(filePath).openStream()); |
| 17 | } else { |
| 18 | return DigestUtils.md5Hex(new FileInputStream(new File( |
| 19 | filePath))); |
| 20 | } |
| 21 | } catch (Exception e) { |
| 22 | // TODO Auto-generated catch block |
| 23 | e.printStackTrace(); |
| 24 | } |
| 25 | return null; |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public String getReferenceKey() { |
| 30 | // TODO Auto-generated method stub |
| 31 | return "md5"; |
| 32 | } |
| 33 | |
| 34 | } |
nothing calls this directly
no outgoing calls
no test coverage detected