Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java impose any further restrictions on filenames other than the underlying operating system?

Does Java impose any extra restrictions of its own. Windows (upto Vista) does not allow names to include

\ / < > ? * :

I know HOW to validate names (a regular expression).

I need to validate filenames entered by users.

My application does not need to run on any other platform, though, of course, I would prefer to be platform independent!

like image 747
David Kerr Avatar asked Nov 05 '22 23:11

David Kerr


1 Answers

No, you can escape any character that Java doesn't allow in String literals but the filesystem allows.

Also, if trying to port an Windows app to Mac or Unix it is best to use:

File.separator

To determine the correct file separator to use on each platform.

like image 82
jjnguy Avatar answered Nov 12 '22 10:11

jjnguy