Reputation: 9023
System.out.println(s.toString().substring(0,s.indexOf(".mp3")));
i am downloading file from android application..
i need to name them as 1 2 3 like that..
so.. i'll need to do is increment the max size of it so i've done the
System.out.println(s.toString().substring(0,s.indexOf(".mp3")));
from this it will give me 1 2 3 that is spite my mp3 file name now i want to fine max of it so i can increment it by 1 but how to do this?
Upvotes: 0
Views: 92
Reputation: 1501013
Well, you could parse each filename (e.g. using Integer.parseInt
).
Alternatively, if you knew you'd have less than (say) 100,000 files, you could format the filenames in a sortable fashion to start with - so instead of 141.mp3, you'd have 00141.mp3. That way you could just sort all the filenames and parse the last one.
Upvotes: 2