Class FilePath

java.lang.Object
org.eclipse.osgi.framework.util.FilePath

public class FilePath extends Object
A utility class for manipulating file system paths.

This class is not intended to be subclassed by clients but may be instantiated.

Since:
3.1
  • Constructor Details

    • FilePath

      public FilePath(File location)
      Constructs a new file path from the given File object.
    • FilePath

      public FilePath(String original)
      Constructs a new file path from the given string path.
  • Method Details

    • getDevice

      public String getDevice()
      Returns the device for this file system path, or null if none exists. The device string ends with a colon.
      Returns:
      the device string or null
    • getSegments

      public String[] getSegments()
      Returns the segments in this path. If this path has no segments, returns an empty array.
      Returns:
      an array containing all segments for this path
    • hasTrailingSlash

      public boolean hasTrailingSlash()
      Returns whether this path ends with a slash.
      Returns:
      true if the path ends with a slash, false otherwise
    • isAbsolute

      public boolean isAbsolute()
      Returns whether this path is absolute (begins with a slash).
      Returns:
      true if this path is absolute, false otherwise
    • makeRelative

      public String makeRelative(FilePath base)
      Returns a string representing this path as a relative to the given base path.

      If this path and the given path do not use the same device letter, this path's string representation is returned as is.

      Parameters:
      base - the path this path should be made relative to
      Returns:
      a string representation for this path as relative to the given base path
    • toString

      public String toString()
      Returns a string representation of this path.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this path