Arrangement of directories on a stick

Hi

I’ve used a FileFilter method to print
all directories on the top level of my usb-stick.
The order is not alphabetically and I wonder why.
I guess Java prints it in the order of
storage on the stick.
I’d like to have them in an alphabetical order because
my carradio plays the directories (albums) in this order that
java prints and which is as it seems a storage-type.
Does anyone now how to change the arrangement of
the directories on the stick ?
Thx :wink:

Copy all files, index them, sort em, and write em back in sorted order.

I have the feeling he just wants the result of File.list() sorted?

The listing of files in a directory Operating System dependant.

I rarely get my results in non-alphabetical order… maybe it is filesystem dependant, NTFS vs FAT32 (on the stick) ?

I know how to sort the File.list() - array.
With Bubblesort or Quicksort or something else, that
is not the problem.
On the stick the file system is FAT32 and
the arrangement on the stick seems to not necessarily be
in alphabetical order.
I will try out oNyx’s idea but this is not the entire solution I need.
I tell you why:
When there’s already some music on the stick
and I add some new files to some of the directories the
order on the stick may change.
I need a way to rearrange the physical directories in alphabetical order,
something comparable to what the defragmentation-tool does on windows.

I hope you understand what I mean, if not, ask me.
I’m really thankful for help because I hear music a lot in the car and
want to have the music in the right order :wink:

Thx so far :slight_smile:

Maybe the answer lies in RandomAccessFiles.

You can write a random bunch of them, all larger than the largest original file.

Then view the order.
Then fill them with actual data.
Then call raf.setLength(…)

I think that keeps files in place, even if they shrink.