| | |
| | | */ |
| | | public static final String projectPath = initProjectPathAndDebug(); |
| | | |
| | | public static String getConfigFilePath(String cfgName) { |
| | | return String.format("%s%s%s", projectPath, getFileSeparator(), cfgName); |
| | | } |
| | | |
| | | /*** |
| | | * 获取项目根路径,无论是打包成jar文件。 |
| | | * 为了保证调试时获取项目路径,而不是bin路径,增加逻辑: 如果以bin目录接,则返回上一层目录 |
| | |
| | | * @return 例如:F:\eclipse\work\JavaFX\AddressApp\build\dist |
| | | */ |
| | | private static String initProjectPathAndDebug() { |
| | | |
| | | if (SystemUtil.isWindows()) { |
| | | System.out.println(".....isWindows...."); |
| | | } |
| | | if (SystemUtil.isMacOs()) { |
| | | System.out.println("....isMacOs....."); |
| | | } |
| | | if (SystemUtil.isLinux()) { |
| | | System.out.println("......isLinux..."); |
| | | } |
| | | |
| | | |
| | | URL url = PathUtil.class.getProtectionDomain().getCodeSource().getLocation(); |
| | | String filePath = null; |
| | | try { |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static String getFileSeparator() { |
| | | return File.separator; |
| | | } |
| | | |
| | | /*** |
| | | * 这个方法打包位jar文件就无法获取项目路径了。 |
| | | * @return |