本文整理汇总了Java中javax.microedition.io.file.FileConnection.availableSize方法的典型用法代码示例。如果您正苦于以下问题:Java FileConnection.availableSize方法的具体用法?Java FileConnection.availableSize怎么用?Java FileConnection.availableSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.io.file.FileConnection
的用法示例。
在下文中一共展示了FileConnection.availableSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test0003
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests totalSize() as the sum of usedSize() and availableSize()
*/
public void test0003() {
boolean passed = false;
try {
FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
try {
long totalSize = conn.totalSize();
addOperationDesc("totalSize()="+totalSize);
long totalSize2 = conn.availableSize() + conn.usedSize();
addOperationDesc("availableSize()+usedSize()="+totalSize2);
passed = totalSize == totalSize2;
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests totalSize() as the sum of usedSize() and availableSize()", passed);
}
示例2: test0005
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests availableSize() in Connector.READ mode
*/
public void test0005() {
boolean passed = false;
try {
addOperationDesc("Opening connection in READ mode");
FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ);
try {
long availableSize = conn.availableSize();
addOperationDesc("availableSize() call returned " + availableSize);
passed = true;
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests availableSize() in Connector.READ mode", passed);
}
示例3: test0001
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public void test0001() {
boolean passed = false;
try {
FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
OutputStream os = null;
try {
addOperationDesc("Creating file: " + conn.getURL());
ensureFileExists(conn);
long availableSize = conn.availableSize();
addOperationDesc("first availableSize() call returned " + availableSize);
int incrementSize = 4096;
byte buf[] = new byte[incrementSize];
os = conn.openOutputStream();
for (int i=0; i<4; i++) {
addOperationDesc("writing " + incrementSize + " bytes to disk");
os.write(buf);
}
os.close();
os = null;
long availableSize2 = conn.availableSize();
addOperationDesc("second availableSize() call returned " + availableSize2 + " (should be less than first call)");
passed = availableSize2<availableSize;
} finally {
if (os != null) os.close();
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests availableSize()", passed);
}