本文介绍了获取目录列表从URL中的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们怎样才能从URL目录列表。例如从abc.com/myfolders?在Android系统。
How can we get the list of directories from a URL. e.g. from abc.com/myfolders? in Android.
如果有一个URL
下列文件夹 - abc.com/myfolders/folder1
- abc.com/myfolders/folder2
- abc.com/myfolders/folder3
- abc.com/myfolders/folder4
If there are following folders in a URL
- abc.com/myfolders/folder1
- abc.com/myfolders/folder2
- abc.com/myfolders/folder3
- abc.com/myfolders/folder4
那么如何才能在列表中填入
then how can the list be populated with
文件夹1
FOLDER2
folder3
folder4
folder1
folder2
folder3
folder4
推荐答案
尝试使用以下code
Try with the following code
String absolutePath = "abc.com/myfolders/folder1";
String directoryName = null;
if((absolutePath != null) && (absolutePath.length()>0)){
int indexOfFileSeparator = absolutePath.lastIndexOf("/");
if (indexOfFileSeparator >= 0) {
directoryName = absolutePath.substring(indexOfFileSeparator + 1);
}
}
System.out.println("...shortStr..." + directoryName);
这篇关于获取目录列表从URL中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!