I think problem comes from the list, when i try to initialize it with an initial size, the debugger shows me that it's size is still 0. When i try to add to the list using list.add(index, file), it throws me an IndexOutOfBounds exception.