Let's say I have my main class in C:\Users\Justian\Documents.
How can I get my program to show that it's in C:\Users\Justian\Documents.
Hard-Coding is not an option- it needs to be adaptable if it's moved to another location.
I want to dump a bunch of CSV files in a folder, have the program recognize all the files, then load the data and manipulate them. I really just want to know how to navigate to that folder.
Many thanks,
Justian
I want to dump a bunch of CSV files in a folder, have the program recognize all the files, then load the data and manipulate them. I really just want to know how to navigate to that folder.
@BalusC
Why is:
public static String getCleanPath() {
ClassLoader classLoader = ExcelFile.class.getClassLoader();
File classpathRoot = new File(classLoader.getResource("").getPath());
return classpathRoot.getPath();
}
Better than:
public static String getCleanPath() {
URL location = ExcelFile.class.getProtectionDomain().getCodeSource()
.getLocation();
String path = location.getFile();
return new File(path).getParent();
}