Search code examples
javaftpapache-commons-net

How to get FTP server's file separator


I am using FTPFile class and I did not find any method or variable which shows the path separator as we do in Files class (File.separator). How can we get the file separator of ftp server using java.Is there any predefined variable or method in FTPFile class?


Solution

  • There's no API for an FTP client to tell remote path separator, not only in Java Apache Commons, but in general.

    Though, most decent FTP servers will use /, even if the actual remote OS use a different separator.

    But the FTP specification does not mandate it. So there are indeed FTP servers that use a different separator. Like the OpenVMS FTP server (mainframe FTP servers in general).