-
Notifications
You must be signed in to change notification settings - Fork 1
Get the directory where a Class (its Package) is stored
Dr. Nicola Mingotti edited this page Dec 11, 2021
·
1 revision
Problem. You need to access some data file. You know it is a bad idea to put an absolute path to say where it is, tomorrow you may move your project in another computer and all those kind of absolute references would be broken. Then, you may know that, for exaple, your data files live in a directory nearby the package that uses them! So, just find where your class/package is and move from there.
Solution. I want to find in which directory the package containing the class Foobar lives, i do like this:
Foobar package packageDirectoryName.
Dr. Nicola Mingotti first wrote this on 21-Sep-2021. Tested in Cuis5.0-4834.image.