File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make it relative path?

 
Max Bean
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I create my FileInputStream like this:

in = new FileInputStream("c:/projects/study/college/test/parameters.xml");

, is there any way else to access parameters.xml without using the hardcoded-path that way?
 
Roger F. Gay
Ranch Hand
Posts: 408
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the path is relative to your application, then:

getPath()
getAbsolutePath()
getCanonicalPath()

If you want a configurable path, place a configuration file where your application knows where to find it (relatively speaking) and read the path from the configuration file.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is an example Code:



is this what you looking for..
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Relative to what might be the question. This line:

will create a file relative to the current user directory. See System Properties to get the current home.

You can also make a file relative to another file or a path string:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic