Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Directory Reference ..  RSS feed

 
Cecil Phillip
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
trying to write a program the refers to a file that resides in another directory in the parent directory of the source. For example

/parent/source/ <code files>
/parent/xml/ <xml files>

I thought I could just do a


that doesn't work though...
anyone know what i could do ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the API documentation of class java.io.File. It contains methods to get the parent directory. It would be something like this:
 
Cecil Phillip
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know and understand the method that you presented. My issue is that it uses and absolute path. I want to be able to refer to the path relatively ....
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the following link for your answer

Java.io.File

In here you can read.

A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.
 
Cecil Phillip
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh ok ... i see where you're coming from. Thank you all very much
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!