1

Possible Duplicate:
Combine paths in Java

Perl has a module called File::Spec that has a catfile() method:

$x = File::Spec->catfile('a', 'b', 'c');

This module returns different results depending on the operating system. The above call gives a file path that on Linux would be /a/b/c, on classic Mac OS would be :a:b:c, and on Windows would be (I believe) a:\b\c (or maybe \a\b\c). File::Spec->catfile() also handles consecutive directory separators, so if you pass in 'a/', '/b' you'd get back a/b.

Is there anything that will do this in Java? I know there's the File.separatorChar and File.separator fields, but I'd really like to just use a method that takes an array of Strings (or a variable number of Strings) and returns a String for the full path.

Community
  • 1
  • 1
CanSpice
  • 34,814
  • 10
  • 72
  • 86

0 Answers0