当前位置: 首页>>代码示例>>Java>>正文


Java FileSystemRegistry.listRoots方法代码示例

本文整理汇总了Java中javax.microedition.io.file.FileSystemRegistry.listRoots方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemRegistry.listRoots方法的具体用法?Java FileSystemRegistry.listRoots怎么用?Java FileSystemRegistry.listRoots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.io.file.FileSystemRegistry的用法示例。


在下文中一共展示了FileSystemRegistry.listRoots方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadRoots

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
private void loadRoots() {
    if (!rootsList.isEmpty()) {
        rootsList.removeAllElements();
    }
    try {
        Enumeration roots = FileSystemRegistry.listRoots();
        while (roots.hasMoreElements()) {
            String r = (String) roots.nextElement();
            rootsList.addElement(FILE_SEPARATOR + r);
        }
    } catch (Throwable e) {
    }
}
 
开发者ID:kamcpp,项目名称:heart-diag-app,代码行数:14,代码来源:FileSelector.java

示例2: roots

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
private Vector<String> roots() {
    if(fileroots == null) {
        fileroots = new Vector<String>();
        try {
            for(Enumeration en = FileSystemRegistry.listRoots(); en.hasMoreElements() ; ) {
                String root = (String)en.nextElement();
                if(root.endsWith("/")) {
                    //cut off any trailing /'s
                    root = root.substring(0, root.length() -1);
                    fileroots.addElement(root);
                }
            }
        } catch(SecurityException e) {
            this.securityException(e);
            if(fileroots.size() > 0 ) {
                //got something....
                return fileroots;
            } else {
                //something happened, probably the user denying access to list the roots.
                //return an empty vector, but set fileroots to null so that it'll try again later
                fileroots = null;
                return new Vector<String>();
            }
        } catch(NullPointerException npe) {
            //This exists simply to catch an error in some (MicroEmu's) implementations of listroots
            return new Vector<String>();
        }
    }
    return fileroots;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:31,代码来源:J2meFileSystemProperties.java

示例3: useSDCard

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
public static boolean useSDCard() {
    String root = null;
    Enumeration e = FileSystemRegistry.listRoots();
    while (e.hasMoreElements()) {
        root = (String) e.nextElement();
        if (root.equalsIgnoreCase("sdcard/")) {
            return true;
        }
    }

    return false;
}
 
开发者ID:yanex,项目名称:vika,代码行数:13,代码来源:DeviceMemory.java

示例4: listRoots

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
public String[] listRoots() {
	Enumeration e = FileSystemRegistry.listRoots();
	ArrayList rootv = new ArrayList();
	while (e.hasMoreElements()) rootv.add(e.nextElement());
	String[] roots = new String[rootv.size()];
	for (int i=0; i<rootv.size(); i++) {
		String str = String.valueOf(rootv.get(i));
		if (!str.endsWith("/")) roots[i] = str+'/';
		else roots[i] = str;
	}
	return roots;
}
 
开发者ID:SBasalaev,项目名称:alchemy-os,代码行数:13,代码来源:Helper.java

示例5: getDirModel

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
private ListModel getDirModel() throws IOException {
    Vector dirList = new Vector();

    Enumeration dirContent = null;
    if (currentDir == null) {
        dirContent = FileSystemRegistry.listRoots();
    } else {
        FileConnection conn = (FileConnection) Connector.open(currentDir, Connector.READ);
        if(conn.exists()) dirContent = conn.list();
        else {
            currentDir = null;
            dirContent = FileSystemRegistry.listRoots();
        }
    }

    if (dirContent != null) {
        if (currentDir != null) dirList.addElement(new UpDirectory());
        while (dirContent.hasMoreElements()) {
            String filename = (String) dirContent.nextElement();

            if (isDirectory(filename)) {
                dirList.addElement(new Directory(filename));
            } else {
                if(!directoriesOnly && (fileEndingFilter == null || "".equals(fileEndingFilter) || filename.toLowerCase().endsWith(fileEndingFilter))) {
                    dirList.addElement(new File(filename));
                }
            }
        }
    }
    
    // sorts the list alphabetically: first up, second dirs, third files
    QuickSorter.sort(dirList);
    
    return new DefaultListModel(dirList);
}
 
开发者ID:csperle,项目名称:KeePassMobile,代码行数:36,代码来源:FileChooserForm.java

示例6: test0001

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
public void test0001() {
	Enumeration e = FileSystemRegistry.listRoots();
	if (e==null) {
		addOperationDesc("Enumeration was null");
		assertTrueWithLog("Tests listRoots()", false);
		return;
	} else {
		addOperationDesc("listRoots() returned:");
		int i= 0;
		while(e.hasMoreElements()) {
			i++;
			String root = (String)e.nextElement();
			addOperationDesc(i + ". " + root);
			if (root==null) {
				addOperationDesc("Root was null");
				assertTrueWithLog("Tests listRoots()", false);
				return;
			}
			if (!root.endsWith("/")) {
				addOperationDesc("Root does not end with slash: " + root);
				assertTrueWithLog("Tests listRoots()", false);
				return;
			}
		}
	}
	
	addOperationDesc("");
	
	boolean passed = false;
	if (!e.hasMoreElements()) {
		try {
			e.nextElement();
			addOperationDesc("NoSuchElementException expected");
			passed = false;
		} catch (NoSuchElementException ex) {
			addOperationDesc("NoSuchElementException thrown as expected");
			passed = true;
		}
	}
	
	assertTrueWithLog("Tests listRoots()", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:43,代码来源:ListRoots.java

示例7: setDir

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
public void setDir(String location) {
	FileConnection dir = null;
	Enumeration fsEnum;
	try {
		if (location == null) {
			fsEnum = FileSystemRegistry.listRoots();
			this.setTitle("FS Roots");
		} else {
			System.out.println("cd " + location);
			String sep = "";
			if (location.charAt(0) != DIR_SEP) {
				sep = String.valueOf(DIR_SEP);
			}
			dir = (FileConnection) Connector.open("file://localhost" + sep + location);
			if (!dir.isDirectory()) {
				FCViewMIDlet.setCurrentDisplayable(new FileEditor(dir, this));
				return;
			}
			this.setTitle(dir.getPath() + dir.getName());
			fsEnum = dir.list();
			System.out.println("new location " + dir.getURL());
		}

		this.deleteAll();
		if (location != null) {
			this.append("..", dirIcon);
		}
		while (fsEnum.hasMoreElements()) {
			String fileName = (String) fsEnum.nextElement();
			if (fileName.charAt(fileName.length() - 1) == DIR_SEP) {
				this.append(fileName, dirIcon);
			} else {
				this.append(fileName, fileIcon);
			}
		}
		if (currentDir != null) {
			currentDir.close();
		}
		currentDir = dir;
	} catch (IOException e) {
		showError(e.getMessage());
	}
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:44,代码来源:FilesList.java

示例8: getRootNames

import javax.microedition.io.file.FileSystemRegistry; //导入方法依赖的package包/类
/**
 * Get a list of root directories on the device
 * @return
 */
public static Enumeration getRootNames() {
    return FileSystemRegistry.listRoots();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:8,代码来源:FileUtility.java


注:本文中的javax.microedition.io.file.FileSystemRegistry.listRoots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。