Results 1 to 3 of 3
- 05-28-2012, 04:53 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 37
- Rep Power
- 0
Current Directory is my user's folder...
Hi, I have a program that creates a file with the name config.dat, but instead of placing it in the folder where jar is, it places it under my C:/Users/User folder, which is not something I want...
The line I use is: 1. FileWriter file = new FileWriter ("config.dat");
If I use: 2. FileWriter filewriter = new FileWriter ("/config.dat"); the file goes to C:/
If I use: 3. String currentDir = new File(".").getAbsolutePath(); File file = new File(currentDir, "config.dat"); FileWriter filewriter = new FileWriter (file); I get the same problem of the first line...
I read Java doesn't consider the currentdirectory as the one where the .class was run from, but the one that called the jvm...
I don't know what to do, please help me a little bit.
- 05-28-2012, 04:58 AM #2
Member
- Join Date
- Apr 2012
- Posts
- 37
- Rep Power
- 0
Re: Current Directory is my user's folder...
I tried this:
String ubicacion = new File(".").getCanonicalPath();
File archivo = new File (ubicacion, "config.dat");
Not working either, same thing than numer 1.
- 05-28-2012, 09:56 AM #3
Re: Current Directory is my user's folder...
Click here
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
changing current directory
By flaca in forum New To JavaReplies: 7Last Post: 03-06-2011, 02:50 AM -
Classpath problem for current directory
By DerekRaimann in forum New To JavaReplies: 10Last Post: 12-08-2010, 12:41 AM -
How to get Current Directory through File
By Java Tip in forum java.ioReplies: 0Last Post: 04-05-2008, 10:14 AM -
How to get the current working directory in EJB?
By sathish_2111 in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 07-19-2007, 04:24 PM -
How can i get current directory?
By Ashley in forum New To JavaReplies: 1Last Post: 05-26-2007, 01:21 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks