A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Java EE 7 Tutorial Volume 1 or Volume 2
this week in the
jQuery UI in Action
new File (Relative Path to a package): How?
Joined: Jul 26, 2011
Aug 16, 2011 21:13:53
1. I used Apache common io.
> lines = FileUtils.readLines("c://etc...//mypackage//io//textfile.txt"); // absolute path
This is absolute path. It works.
List<String> lines = FileUtils.readLines("mypackage/io/textfile.txt"); // relative to a package
Exception in thread "main"
Syntax-wise or class-wise or xyz: How can I make it by using relative path to a package?
Joined: Oct 14, 2005
Aug 16, 2011 22:53:34
First you get a File object which represents the "package" -- whatever you mean by that.
File packageFile = ...
Then you use the File constructor which allows you to create a File relative to another File:
File dataFile = new File(packageFile, "mypackage/io/textfile.txt");
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: new File (Relative Path to a package): How?
Writting a String to a file
genarate PDf and save it on server
Not able to find a File in servlet
Send lines of a file to something such as an arrayList
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014