Article View: borland.public.jbuilder.java.api
Article #293Re: How to get path to current directory?
From: Scott
Date: Sat, 03 Apr 2004 16:53
Date: Sat, 03 Apr 2004 16:53
69 lines
2512 bytes
2512 bytes
Tomek,
I noticed this on the web, too:
import java.io.File;
public class CurrentDir {
public static void main (String args[]) {
File dir1 = new File (".");
File dir2 = new File ("..");
try {
System.out.println ("Current dir : " + dir1.getCanonicalPath());
System.out.println ("Parent dir : " + dir2.getCanonicalPath());
}
catch(Exception e) {
e.printStackTrace();
}
}
}at http://www.rgagnon.com/javadetails/java-0076.html"Scott"
<scotthpowell@yahoo.com> wrote in message
news:406ee0c2$1@newsgroups.borland.com...
> Tomek,
>
> I'm new to Java, so I don't know how good this advice is, but try:
>
> String mypath = System.getProperty("user.dir");
>
>
>
> That gave me the name of the directory in which my test app was running.
>
> Coverage is here:
>
>
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties()
>
> and
>
>
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperty(java.lang.String)
>
> Hope that helps.
>
>
>
> Scott
>
>
>
>
>
>
>
> "Tomek" <pantomaszw@poczta.onet.pl> wrote in message
> news:blh1f6$839$1@mail.sources.pl...
> > Hello.
> >
> > How to get path to current directory and put this path to object of
class
> > String?
> > I found FileSystemView.getHomeDirectory() but it returns path to home
> > directory for example:
> >
> > C:\Documments and Settings\Thomas
> >
> > Thanks for help.
> >
> >
> >
>
>
Technical Details
Message-ID:
<406eec4f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<blh1f6$839$1@mail.sources.pl> <406ee0c2$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,66fe2e00e1cfc947 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2004-04-03 09:10:00 PST Reply-To: "Scott" <scotthpowell@yahoo.com> From: "Scott" <scotthpowell@yahoo.com> Newsgroups: borland.public.jbuilder.java.api References: <blh1f6$839$1@mail.sources.pl> <406ee0c2$1@newsgroups.borland.com> Subject: Re: How to get path to current directory? Date: Sat, 3 Apr 2004 11:53:24 -0500 Lines: 71 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 24.239.150.17 Message-ID: <406eec4f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081011279 24.239.150.17 (3 Apr 2004 08:54:39 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail