Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-549

Replace System.getProperty("file|path.separator") with File.separator|pathSeparator

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1
    • Labels:
      None

      Description

      The file separator character is available from both File.separator and System.getProperty("file.separator").

      The former is guaranteed to be a string of length 1, but the latter can be defined as a longer string on the Java command line. Thus the two can be different, but still allow the JVM to start up.
      I found the following worked:

      java -Dfile.separator=/xyz

      for Unix or the equivalent \xyz on Windows.

      [Using a different first character does not work - the JVM usually throws an
      exception as it cannot find some required files if the sep. is incorrect.]

      It looks like only the first character of the property is used by the JVM.
      However, this is not done by the application code I have seen, which means that there could be a discrepancy between the two methods.

      File.separator has the additional benefit that it is not subject to a privilege
      check.

      The same reasoning applies to "path.separator" => File.pathSeparator

      Commons code should always use the File constants.

        Attachments

        1. VER-549.patch
          0.9 kB
          Simon Legner

          Activity

            People

            • Assignee:
              b.eckenfels Bernd Eckenfels
              Reporter:
              sebb Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: