java字符串函数需要帮助

发布于 2024-11-11 18:25:58 字数 335 浏览 5 评论 0原文

System.out.println(s.toString().substring(0,s.indexOf(".mp3")));

我正在从 Android 应用程序下载文件..
我需要将它们命名为 1 2 3 这样.. 所以..我需要做的是增加它的最大大小,所以我已经完成了

System.out.println(s.toString().substring(0,s.indexOf(".mp3")));

,它会给我 1 2 3 尽管我的 mp3 文件名现在我想调整它的最大值所以我可以将其增加 1,但是该怎么做呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风追烟花雨 2024-11-18 18:25:58

好吧,您可以解析每个文件名(例如使用Integer.parseInt)。

或者,如果您知道自己的文件少于(例如)100,000 个,则可以首先以可排序的方式格式化文件名 - 因此您将拥有 00141.mp3,而不是 141.mp3。这样你就可以对所有文件名进行排序并解析最后一个。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文