简体   繁体   中英

Relative Path in Other Java Class

How are you?

I'm working into a Java Project and my IDE is Eclipse. What's going on is that I have a Constants.java to set some paths to get into other classes, but Eclipse can't locate the file I have to find.

The code line here is on Constants.java to get a spreadsheet that is in dataDriver inside my project.

public static final String File_Path = "../../../../../../dataDriver/DataFile.xlsx";

Anybody could help me getting this file?

If the file is in your project then use this:

public static final String File_Path = "./dataDriver/DataFile.xlsx";

'.' is used for current directory and '..' is used for parent directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM