本文整理汇总了Java中javax.microedition.io.file.FileConnection.directorySize方法的典型用法代码示例。如果您正苦于以下问题:Java FileConnection.directorySize方法的具体用法?Java FileConnection.directorySize怎么用?Java FileConnection.directorySize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.io.file.FileConnection
的用法示例。
在下文中一共展示了FileConnection.directorySize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test0001
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests directorySize() on empty directory
*/
public void test0001() {
boolean passed = false;
try {
FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
try {
addOperationDesc("Creating directory: " + conn.getURL());
ensureDirExists(conn);
long directorySize = conn.directorySize(true);
addOperationDesc("directorySize(true) returned " + directorySize);
passed = directorySize==0;
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests directorySize() on empty directory", passed);
}
示例2: test0008
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests directorySize() in Connector.READ mode
*/
public void test0008() {
boolean passed = false;
try {
addOperationDesc("Opening connection in READ mode");
FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ);
try {
long directorySize = conn.directorySize(false);
addOperationDesc("directorySize() call returned " + directorySize);
passed = true;
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests directorySize() in Connector.READ mode", passed);
}
示例3: test0009
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests directorySize() on a non-existent directory
*/
public void test0009() {
boolean passed = false;
try {
FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
try {
addOperationDesc("Deleting directory: " + conn.getURL());
ensureNotExists(conn);
long directorySize = conn.directorySize(true);
addOperationDesc("directorySize(true) returned " + directorySize);
passed = directorySize==-1;
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests directorySize() on a non-existent directory", passed);
}
示例4: getDirectorySize
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public static long getDirectorySize(String path) {
try {
FileConnection fc = (FileConnection) Connector.open(path, Connector.READ);
long size = fc.directorySize(true);
fc.close();
return size;
} catch (Exception e) {
return -1;
}
}