πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14586

AW: Absolute path to class file

#14586
From: gregor.schneider
Date: Tue, 17 Aug 1999 00:00
53 lines
2018 bytes
howdy,

> Von: 	Ben Starr[SMTP:bens@compurp.org.uk]
> Betreff: 	Re: Absolute path to class file
> 
> 
> Actually, I was after the file path (eg:
> c:\someclasspathroot\packagepath\myclass.class).
> 
well, this is difficult, because you don't know from where your application
is being called (depends on the classpath-setting).

either you use a 

String s = (new java.io.File(".")).getAbsolutePath()

then you have the path where your application has been called (unless you
don't change the directory in your application).

better solution:

InputStream is = YourClass.getRessourceAsStream(String theFileWithoutPath);
(( has to be stored in the same directory as your class).

or, if it's in another directory:

UnputStream is = YourClass.getRessourceAsStream(String
theFileWithPathStartingInDirectoryWhereClassFileIsStored); (( eg. class-file
is in c:\test and text-file is in c:\test\files\file.txt, then the string
yould be "files\file.txt")

take a look at java.lang.Class for further documentation.

regards

--

Gregor Schneider

Gerling-Konzern
Ges. fΓΌr Informationsmanagement und Organisation mbH
Anwendungsentwicklung II - Zentrale Anwendungskomponenten

phone:	+49-221-144-4637
fax:	+49-221-144-66837
web:	http://www.gerling.de



 Sent via Deja.com http://www.deja.com/
 Share what you know. Learn what you don't.
Technical Details
Message-ID: <B60F13A5F741D3118DAD00508B135E99BA2A4E@S-D-K-01.gerling.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,488dd600984f352c
X-Google-Attributes: gidf74b3,public
From: gregor.schneider@gerling.de
Subject: AW: Absolute path to class file
Date: 1999/08/17
Message-ID: <B60F13A5F741D3118DAD00508B135E99BA2A4E@S-D-K-01.gerling.de>
X-Deja-AN: 513778615
Content-Transfer-Encoding: quoted-printable
To: borland.public.jbuilder.java.language@list.deja.com
X-DejaID: _9S5sGRHcNJLdTEqeW6kkMA=
Content-Type: text/plain
Organization: Deja.com - Share what you know. Learn what you don't.
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language