Skip to main content
added 110 characters in body
Source Link
sportsfan72
  • 301
  • 3
  • 8
  • 16

How do I get the directory where the a .java file is located? I don't want to use System.getProperty("user.dir"), because that gives me the directory of the executable, and not the directory of the .java file that contains this line of code.

I need this because I'm developing a JSP web-app, and the Java code creates a .csv file on the server side and I want to make it available on the client side, but I would need to place the csv file where the location of the .html files are so that they could be downloaded.

My current folder structure is like:

Java Resources ->src
->.java file

WebContent
->.html file

How do I get the directory where the a .java file is located? I don't want to use System.getProperty("user.dir"), because that gives me the directory of the executable, and not the directory of the .java file that contains this line of code.

I need this because I'm developing a JSP web-app, and the Java code creates a .csv file on the server side and I want to make it available on the client side, but I would need to place the csv file where the location of the .html files are so that they could be downloaded.

How do I get the directory where the a .java file is located? I don't want to use System.getProperty("user.dir"), because that gives me the directory of the executable, and not the directory of the .java file that contains this line of code.

I need this because I'm developing a JSP web-app, and the Java code creates a .csv file on the server side and I want to make it available on the client side, but I would need to place the csv file where the location of the .html files are so that they could be downloaded.

My current folder structure is like:

Java Resources ->src
->.java file

WebContent
->.html file

Source Link
sportsfan72
  • 301
  • 3
  • 8
  • 16

Get Path of current file

How do I get the directory where the a .java file is located? I don't want to use System.getProperty("user.dir"), because that gives me the directory of the executable, and not the directory of the .java file that contains this line of code.

I need this because I'm developing a JSP web-app, and the Java code creates a .csv file on the server side and I want to make it available on the client side, but I would need to place the csv file where the location of the .html files are so that they could be downloaded.