简体   繁体   中英

java string function need help

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?

Well, you could parse each filename (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM