Class ExampleData
These data files ride in the jar as resources, while Replayer and
every other reader here open a PATH rather than a stream, so the resource has
to become a file before it can be read. Paths.get(url.toURI()) is the
obvious conversion and it is the one that breaks: loaded from
common/jline.jar the URL is
jar:file:/...jline.jar!/example_trace.txt, and the jar scheme
has no mounted FileSystemProvider, so Paths.get throws
FileSystemNotFoundException -- an UNCHECKED exception
that a catch (URISyntaxException) beside it does not stop. That is how
GettingStarted.tut02_mg1_multiclass_solvers died in every release
archive while passing in a development tree, where the same resource is a
plain file: URL under target/classes.
So a file: resource is used where it lies, and anything else is
extracted once to a temp file that lives as long as the JVM. Nothing here
consults the working directory: an example must not depend on where it was
started from.
-
Method Summary
-
Method Details
-
path
The path of a data file shipped as a resource, e.g."/example_trace.txt".- Parameters:
resource- absolute resource name, leading slash included- Returns:
- the absolute path of a file that exists and is readable
- Throws:
IllegalStateException- if the resource is not on the classpath, or cannot be extracted
-