Results 1 to 9 of 9
- 11-02-2012, 01:01 PM #1
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 2
new File(Project's folder) how do I get that?
Hi, I need the File to be the project's folder, and I can't seemed to figure how to do that...
If I write in the File folder's name that located in that project, it works, but if I will I can't get the project's folder it's self...
Help?WARNING I am Russian so it's possible that I wont understand you correctly...
- 11-02-2012, 01:18 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: new File(Project's folder) how do I get that?
If you're writing an application then do you really want to be thinking in terms of a project folder?
Please do not ask for code as refusal often offends.
- 11-03-2012, 03:12 PM #3
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 2
Re: new File(Project's folder) how do I get that?
I am writing server for a personal use, without exporting it, so yeah..
WARNING I am Russian so it's possible that I wont understand you correctly...
-
Re: new File(Project's folder) how do I get that?
Please explain in more detail. What exactly are you trying to do and why?
- 11-04-2012, 12:15 AM #5
Senior Member
- Join Date
- Oct 2012
- Posts
- 108
- Rep Power
- 0
Re: new File(Project's folder) how do I get that?
I don't know if this is what you mean, but this will tell you where you are.Java Code:File nf = new File(""); System.out.print(nf.getAbsolutePath());
-
Re: new File(Project's folder) how do I get that?
If he's looking for the jar's location, your method may fail if it is called from a different directory. For example, compare the results obtained in the following code, especially if jar'd and called from another location:
Java Code:import java.io.File; import javax.swing.JOptionPane; public class TestWhereIAm { public static void main(String[] args) { String whereIAmString = "using user.dir: " + System.getProperty("user.dir") + "\n"; File nf = new File(""); whereIAmString += "using getAbsolutePath: " + nf.getAbsolutePath() + "\n"; whereIAmString += "using protection dom: " + TestWhereIAm.class.getProtectionDomain().getCodeSource().getLocation(); JOptionPane.showMessageDialog(null, whereIAmString); } }
- 11-07-2012, 12:22 PM #7
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 2
Re: new File(Project's folder) how do I get that?
Sorry for a long no response.
Well when I use File nf = new File(""); it gives me an error for some reason... and if I will use File nf = new File("bin/"); it will work perfectely.. (I've placed the files to the bin folder when I tried to test File nf = new File("bin/");)WARNING I am Russian so it's possible that I wont understand you correctly...
- 11-07-2012, 12:44 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: new File(Project's folder) how do I get that?
In most OSes '.' is "current directory".Java Code:File f = new File(".");Please do not ask for code as refusal often offends.
- 11-07-2012, 01:36 PM #9
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 2
Similar Threads
-
copying file from one folder to another maintaining the file structure in java
By rahggupt in forum New To JavaReplies: 0Last Post: 11-12-2011, 01:26 PM -
STRUTS 2 project folder hierarchy
By buyapentiumjerk in forum Web FrameworksReplies: 3Last Post: 06-18-2011, 05:50 PM -
How to Add Poratl Project Folder to Eclipse ?
By gb.rashu in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-07-2010, 08:34 AM -
How to create an access folder for a project in the Jboss server
By satya kishore in forum Web FrameworksReplies: 0Last Post: 02-09-2009, 12:31 PM -
Can we Add lib folder insdie Project JAR file ?
By mahendra.athneria in forum AWT / SwingReplies: 1Last Post: 01-30-2009, 05:51 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks