applet
and main
action tests read from data
files?When jtreg is executed, it cd's
into a scratch area to
ensure that a test can not alter the test suite. Thus, a direct reference to a
data file without some sort of indicator as to where the test was originally
located will fail.
The system property test.src
contains the name of the directory
where the test source resides. The following example illustrates how to read
the data file foo
which is contained in the test source directory.
Note that the default value of "."
allows this test to run both
with the harness, and without (in the source directory).
File f = new File(System.getProperty("test.src", "."), "foo"); InputStream in = new File(f);