简体   繁体   中英

How to add relative path to my script file in java?

I have a directory structure as follows:

Service | src | com.abc.SaaSPlugin | myDb.sql

How can I get the relative path so that I can read the sql file and run the script.

You could do something like

String absPath = new File("src/com/abc/SaaSPlugin/myDb.sql").getAbsolutePath();

You could also move the file to a different folder for ease of use ie

project
  -- Resources
  --src
    --abc ......

Put the myDb.sql in resources folder and then code will be..

String absPath = new File("Resources/myDb.sql").getAbsolutePath();

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