Search for repeated files within an ArrayList in java

1

My question is this, is it possible to search for files with the same name or similar within an ArrayList? For example: I have an arraylist loaded with 5 mp3 files (in this case they are music files) but it is applicable to any type of existing files)

  • Ricky Martin ft Maluma - Vente Pa Ca.

  • Román El Original ft. RC - I want to dance with you.

  • I'm Going Party - Sensato Ft. Pitbull.

  • I'm Going Party - Sensato Ft. Pitbull Dj Asus ft Dj Alonso.

  • Blackmail - Shakira ft Maluma.

What I want to do is perform a search of a specific directory (which I already do) and load all the file names in an arraylist and then compare if they are repeated or similar, in this case within the array those that they are repeated are:

  • I'm Going Party - Sensato Ft. Pitbull.

  • I'm Going Party - Sensato Ft. Pitbull Dj Asus ft Dj Alonso.

While the names are not exactly identical, what I want is that regardless of the similarities or differences that exist in the system can identify those files as the same name, is it possible to do something like that in java? Any element or tool that has the language to perform the search.

I would appreciate your help, thank you very much.

    
asked by Gerardo Ferreyra 05.11.2017 в 03:49
source

2 answers

0

Bearing in mind that all the mp3 files you have named follow the structure (name song) "-" (artist or artists) what I would do would be to use the split function ("-") and this would split the song into an array of 2 cells in cell 0 would be the name of the song and in cell 1 would be the artists or the artist.

After having the mp3 files separated by song name and artists you can filter the songs more easily.

    
answered by 05.11.2017 в 14:01
0

Of course you can. It's a question of being creative. The only pattern that I see that remains constant is:

  • I'm Going Party - Sensato Ft. Pitbull.
  • I'm Going Party - Sensato Ft. Pitbull Dj Asus ft Dj Alonso.

means "I'm Going Party -" is the same in all texts. The delimiter is the script (-) for what you can do:

  • texto.split ("-")

That will allow you to separate the text and then you have to make the comparisons which I suggest the following: Remove duplicates

    
answered by 06.11.2017 в 03:28