How can we store a file with the same name in capital and small letters in java

advertisements

I am creating a xml file using jaxb JAVA and xml file name given by user input using Jtextfield.when user is giving same name 2 times one in capital letters and another one in small letters its overidden the existing file how can we store file with same name in capital and small letters in java?


Generally speaking, you can't.

File names are OS dependent.

The best you can do is provide a warning to the user that they are overwriting the same file. See File.exists

The other solution is to always capitalise (or not) the first character