本文整理汇总了Java中javax.microedition.io.file.FileSystemRegistry类的典型用法代码示例。如果您正苦于以下问题:Java FileSystemRegistry类的具体用法?Java FileSystemRegistry怎么用?Java FileSystemRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemRegistry类属于javax.microedition.io.file包,在下文中一共展示了FileSystemRegistry类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFilesystemRoots
import javax.microedition.io.file.FileSystemRegistry; //导入依赖的package包/类
/**
* @inheritDoc
*/
public String[] listFilesystemRoots() {
String[] res = enumToStringArr(FileSystemRegistry.listRoots());
for(int iter = 0 ; iter < res.length ; iter++) {
res[iter] = "file:///" + res[iter];
}
return res;
}
示例2: listFilesystemRoots
import javax.microedition.io.file.FileSystemRegistry; //导入依赖的package包/类
/**
* @inheritDoc
*/
public String[] listFilesystemRoots() {
String[] res = enumToStringArr(FileSystemRegistry.listRoots());
for (int iter = 0; iter < res.length; iter++) {
res[iter] = "file:///" + res[iter];
}
return res;
}
示例3: FileSelector
import javax.microedition.io.file.FileSystemRegistry; //导入依赖的package包/类
FileSelector(HeartDiagAppMidlet heartDiagApp) {
super("File Browser", List.IMPLICIT);
this.heartDiagApp = heartDiagApp;
deleteAll();
addCommand(selectCommand);
addCommand(backCommand);
setSelectCommand(selectCommand);
setCommandListener(this);
FileSystemRegistry.addFileSystemListener(FileSelector.this);
execute();
}
示例4: 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) {
}
}
示例5: FileSelector
import javax.microedition.io.file.FileSystemRegistry; //导入依赖的package包/类
FileSelector(HeartDiagAppMidlet heartDiagApp) {
super("File Browser", List.IMPLICIT);
this.heartDiagApp = heartDiagApp;
deleteAll();
addCommand(selectCommand);
addCommand(backCommand);
setSelectCommand(selectCommand);
setCommandListener(this);
FileSystemRegistry.addFileSystemListener(FileSelector.this);
execute();
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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);
}
示例10: getRootNames
import javax.microedition.io.file.FileSystemRegistry; //导入依赖的package包/类
/**
* Get a list of root directories on the device
* @return
*/
public String[] getRootNames() throws FileException
{
return enumtoStringArr( FileSystemRegistry.listRoots() );
}
示例11: 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);
}
示例12: openRoot
import javax.microedition.io.file.FileSystemRegistry; //导入依赖的package包/类
private void openRoot() {
currentElements = FileSystemHelper.getElementsList(FileSystemRegistry.listRoots());
}
示例13: 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());
}
}
示例14: 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();
}