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


Java FileConnection.isDirectory方法代码示例

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


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

示例1: test0001

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests isDirectory() on a file
 */
public void test0001() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			boolean isDirectory = conn.isDirectory();
			addOperationDesc("isDirectory() returned " + isDirectory);
			
			passed = isDirectory==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests isDirectory() on a file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:IsDirectory.java

示例2: test0002

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests isDirectory() on a directory
 */
public void test0002() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating directory: " + conn.getURL());
			ensureDirExists(conn);
			
			boolean isDirectory = conn.isDirectory();
			addOperationDesc("isDirectory() returned " + isDirectory);
			
			passed = isDirectory==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests isDirectory() on a file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:IsDirectory.java

示例3: test0003

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests isDirectory() on a non-existent file URL
 */
public void test0003() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir", Connector.READ_WRITE);
		try {
		
			addOperationDesc("Deleting file: " + conn.getURL());
			ensureNotExists(conn);
			
			boolean isDirectory = conn.isDirectory();
			addOperationDesc("isDirectory() returned " + isDirectory);
			
			passed = isDirectory==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests isDirectory() on a non-existent file URL returns false", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:27,代码来源:IsDirectory.java

示例4: test0004

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests isDirectory() on a non-existent directory URL
 */
public void test0004() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Deleting directory: " + conn.getURL());
			ensureNotExists(conn);

			boolean isDirectory = conn.isDirectory();
			addOperationDesc("isDirectory() returned " + isDirectory);
			
			passed = isDirectory==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests isDirectory() on a non-existent directory URL returns false", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:IsDirectory.java

示例5: listDirectory

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public static RichVector listDirectory(FileSystemObject dir, RichVector ext) {
    RichVector ret = new RichVector();

    String path = dir.where + dir.name;

    try {
        FileConnection fileConnection = (FileConnection) Connector.open(path);
        if (fileConnection.isDirectory()) {
            Enumeration enum = fileConnection.list();
            while (enum.hasMoreElements()) {
                String n = ((String) enum.nextElement()).trim();
                String dn = StringUtils.replace(n, "/", "");

                boolean add = true;

                if (dir.where.equals("file:///") && dir.name.equals("store/")) {
                    if (!n.equals("home/")) {
                        add = false;
                    }
                }
                if (dir.where.equals("file:///store/") && dir.name.equals("home/")) {
                    if (!n.equals("user/")) {
                        add = false;
                    }
                }

                if (!n.equals(".") && !n.equals("..")) {
                    if (!n.endsWith("/")) {
                        if (DeviceMemory.matches(n, ext) && add) {
                            ret.addElement(new FileSystemObject(path, dn, n, true));
                        }
                    } else {
                        if (add) {
                            ret.addElement(new FileSystemObject(path, dn, n, false));
                        }
                    }
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

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


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