fileName = entry.getName();
// extract data
// open output streams
} catch (IOException e) {
throw new InternalException(e);
}
}
int locationOfDot = fileName.lastIndexOf(".");
if (locationOfDot == -1 || locationOfDot == fileName.length() - 1) {
throw new UserException(
"The file name must have an extension (eg. '.zip')");
}
int location2Dot = fileName.lastIndexOf(".", locationOfDot - 1);
if (location2Dot != -1) {
locationOfDot = location2Dot;
}
String extension = fileName.substring(locationOfDot + 1);
NonCoreContract parserContract = NonCoreContract
.getNonCoreContract("bill-parser-" + extension);
try {
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec(parserContract.getChargeScript());
PyObject parserClass = interpreter.get("Parser");
parser = (BillParser) parserClass
.__call__(
PyJavaType.wrapJavaObject(new InputStreamReader(is,
"UTF-8"))).__tojava__(BillParser.class);
} catch (UnsupportedEncodingException e) {
throw new InternalException(e);
}
}