...
Code Block |
---|
|
package org.tupeloproject.kernel;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class ExampleContext extends Context {
public void doPerform(BlobFetcher bf) throws OperatorException {
String pathname = bf.getUri().toString().replaceFirst("http://foo.bar.baz/quux", "/usr/share/data/fbbq");
try {
bf.setInputStream(new FileInputStream(pathname));
} catch (FileNotFoundException e) {
throw new NotFoundException("no file found for URI "+bf.getUri(), e);
}
}
}
|
And here's how it would be used to read a file:
Code Block |
---|
|
ExampleContext ec = new ExampleContext();
BlobFetcher bf = new BlobFetcher();
bf.setUri(URI.create("http://foo.bar.baz/quux/some/file.txt"));
ec.perform(bf);
InputStream is = bf.getInputStream();
...
|