0

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?

4

2 回答 2

4

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

于 2012-08-23T05:05:58.450 回答
2

This isn't a Java issue, but a question for the underlying Operating System. Some allow you to create two files that only differ in capitalization (for example Linux), and some don't (Windows, for example).

There is nothing Java can do about it.

于 2012-08-23T05:06:00.370 回答