-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 simon wrote: > On Sun, 2008-02-24 at 14:43 +0100, tarjei wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Hi, I got a test that needs to read a file in src/test/resources. How >> should I write the test to get the information about the relative path >> to that file, either using TestNG or just plain Junit? > > It's best to avoid files at all. Where possible, I suggest using > Class.getResourceAsStream(...) > to access the data you want. The stuff in src/test/resources is on the > classpath. > > If you really need a File object, then try > URL url = Class.getResource(...); > File f = url.tgetFile() > Thanks, that nailed it.
Tarjei > Regards, > Simon > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHwZPkYVRKCnSvzfIRAnGUAKCvNN6olUYXmpnkN8ijPjMO29cT/gCcDDkr vxApKdlxKGixGolmnGYTC60= =SNoo -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
