Re: Incorporating data files into packages and accessing internally
- From: Philipp Taprogge <Philipp.Taprogge@xxxxxxx>
- Date: Tue, 31 Jul 2007 22:54:29 +0200
Hi!
Thus spake Todd on 07/31/2007 10:42 PM:
Do I just create a folder within
my structure that holds the data files and then jar in the normal
manner?
You can do that, yes.
Furthermore, I would like to be able to open and read the contents of
the data files within the package without having to know its path on
the disk.
No problem. When your data is located inside the jar that also contains your
application, you can just access it via the application's Classloader.
You'd do something like this:
InputStream is =
this.getClass().getResourceAsStream("/path/inside/jar/data.file");
I would like to think that I can access a data file within
a package in a manner similar to accessing another class in the
package.
That's exactly what getResourceAsStream() does.
HTH,
Phil
.
- References:
- Prev by Date: Re: Custom JPanels inside another JPanel.
- Next by Date: Re: Incorporating data files into packages and accessing internally
- Previous by thread: Incorporating data files into packages and accessing internally
- Next by thread: Re: Incorporating data files into packages and accessing internally
- Index(es):
Relevant Pages
|