Biscuit128
Biscuit128

Reputation: 5408

Path to file in src directory

I am using a method that requires a string path to a file that is in my src directory structure in eclipse. Is the path to this file simply src\fileName.txt or is there a different way i should be getting this file as it doesnt seem to be working currently

Thanks

Upvotes: 0

Views: 5646

Answers (2)

Farhan Syed
Farhan Syed

Reputation: 326

Run this and you will never forget how to remember.

File file = new File("sample.txt"); System.out.println(file.getAbsolutePath());

Upvotes: 3

thatidiotguy
thatidiotguy

Reputation: 9011

If you are following the maven standard directory structure, class files will be located relative to the classpath like so:

If you want SomeClass.class, you would access it by com.mydomain.packageorappname.deeperpackage.SomeClass. Is that what you are asking?

Upvotes: 0

Related Questions