Jon Chryst Andoque Campos :
I am trying to make a system which involves "file management" so the only thing that bothers me is how to rename file duplicates like for example:
- "Cat.docx" becomes Cat(1).docx
- "Cat(1).docx" also becomes Cat(2).docx and so on...
I also understand the other thread answers related to my question here But I am using Mysql Database with Java and I honestly cannot think of a way to adapt it in my case.
Anyone with an idea about it, please share. Thanks a lot!
oxy_js :
If you are storing fileName in database, then you can follow these steps
If you are getting a file name file.txt then make a call to db with
select count(*) from table where fileNmae="file.txt"
If this count is greater than 0 then insert file into table with name file(1).txt (for renaming follow link)
- If count is 0 then directly insert the original name into table.
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=344778&siteId=1