Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Java Load File Location?

Thread view: 
RigasMinho - 20 Nov 2006 15:25 GMT
I have this: Simple java code that loads in a properties file or an INI
file.

Same thing - compiles and works:

Properties defaultProps = new Properties();
FileInputStream in = new FileInputStream("Test.properties");
defaultProps.load(in);
in.close();

Here's the deal though - it only works if the test.properties file is
located in the same directory as the java file.

meaning d:\Javafiles\Properties.java -the folder javafiles has also the
file Test.Properties in the directory as well.

Is it possible to put the Test.properties file in say the C: drive and
call upon it that way?

I tried this:
FileInputStream in = new FileInputStream("c:\Test.properties");
but i get errors.

Any ideas?
Andreas Wollschlaeger - 20 Nov 2006 19:06 GMT
> I have this: Simple java code that loads in a properties file or an INI
> file.
[quoted text clipped - 20 lines]
>
> Any ideas?

Remember to double backslashes when used in a String literal,
"c:\\Test.properties" should work. Maybe it's even simpler to use a
forward slash : "C:/Test.properties" - avoids the backslash escaping
disease!

HTH
Andreas
Jean-Francois Briere - 20 Nov 2006 19:33 GMT
> avoids the backslash escaping disease!

ha ha! good one :-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.