According to this Wikipedia page , Windows APIs process '/' as the equivalent of '\'. Therefore, even if you somehow enter "/" in the path component in the (for example) File object, there is a chance that Windows will at some point consider it as a path separator.
So your best options are:
- Let Windows handle the "/" as usual; that is, allow processing of the character as a path separator.
- As stated above, but with a warning to the user about '/'.
- Check the characters '/' AND '\' and reject both claims that the file name (i.e. path component) cannot contain path separators.
(The best of the best depends on the details of your application, for example, whether you can report problems to the person who entered the fake file name.)
If you try to treat "/" differently than "\", you run the risk of creating more problems than you solve; for example, if your application needs to be scripted. If you quietly separate one or both characters (or turn them into something else), there is a risk that you will create additional problems; for example unexpected path conflicts.
(Initially, I suggested using the File(URL) constructor File(URL) on the βfile:β URL with the% -escaped '/' symbol. But even if this worked on the Java side, it will not work on the Windows side.)
source share