本文整理汇总了Java中javax.microedition.io.file.FileConnection.getName方法的典型用法代码示例。如果您正苦于以下问题:Java FileConnection.getName方法的具体用法?Java FileConnection.getName怎么用?Java FileConnection.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.io.file.FileConnection
的用法示例。
在下文中一共展示了FileConnection.getName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test0001
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on a non-existing file url
*/
public void test0001() {
boolean passed = false;
try {
String url="file://"+getTestPath()+"file";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
ensureNotExists(conn);
try {
addOperationDesc("Using file url: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = "file".equals(name);
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on a non-existing file url", passed);
}
示例2: test0002
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on a non-existing directory url
*/
public void test0002() {
boolean passed = false;
try {
String url="file://"+getTestPath()+"dir/";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
ensureNotExists(conn);
try {
addOperationDesc("Using directory url: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = "dir/".equals(name);
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on a non-existing directory url", passed);
}
示例3: test0003
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on an existing file url
*/
public void test0003() {
boolean passed = false;
try {
String url="file://"+getTestPath()+"file";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
ensureFileExists(conn);
try {
addOperationDesc("Using file url: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = "file".equals(name);
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on an existing file url", passed);
}
示例4: test0004
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on an existing directory url
*/
public void test0004() {
boolean passed = false;
try {
String url="file://"+getTestPath()+"dir/";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
ensureDirExists(conn);
try {
addOperationDesc("Using directory url: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = "dir/".equals(name);
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on an existing directory url", passed);
}
示例5: test0007
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on an encoded file URL
*/
public void test0007() {
boolean passed = false;
try {
String url="file://"+getTestPath()+"foo%5e%25bar";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
try {
addOperationDesc("Using file url: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = "foo^%bar".equals(name);
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on an encoded file URL", passed);
}
示例6: test0008
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests if getName() returns in unescaped URL format
*/
public void test0008() {
boolean passed = false;
try {
String unEscapedUrl ="file://"+getTestPath()+ "a file";
FileConnection conn = (FileConnection)Connector.open(unEscapedUrl, Connector.READ_WRITE);
try {
addOperationDesc("Using file url: " + unEscapedUrl);
String name = conn.getName();
addOperationDesc("getName() returned: " + name);
passed = name.equals("a file");
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests if getName() returns in unescaped URL format", passed);
}
示例7: test0009
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on a file url with host
*/
public void test0009() {
boolean passed = false;
try {
String url = "file://" + URLSupport.getPathWithHost(getTestPath())+ "file";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
try {
addOperationDesc("Using file url with host: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = name.equals("file");
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on a file url with host", passed);
}
示例8: test0005
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on an existing file, and a connection url ending with '/'
*/
public void test0005() {
boolean passed = false;
try {
String url0="file://"+getTestPath()+"file";
FileConnection conn0 = (FileConnection)Connector.open(url0, Connector.READ_WRITE);
addOperationDesc("Creating file: " + url0);
ensureFileExists(conn0);
conn0.close();
String url="file://"+getTestPath()+"file/";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
try {
addOperationDesc("Using directory url: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = "file".equals(name);
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on an existing file, and a connection url ending with '/'", passed);
}
示例9: test0006
import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
* Tests getName() on an existing directory, and a connection url not ending with '/'
*/
public void test0006() {
boolean passed = false;
try {
String url0 = "file://" + getTestPath() + "dir/";
FileConnection conn0 = (FileConnection)Connector.open(url0, Connector.READ_WRITE);
addOperationDesc("Creating directory: " + url0);
ensureDirExists(conn0);
conn0.close();
String url = "file://" + getTestPath() + "dir";
FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
try {
addOperationDesc("Using file url: " + url);
String name = conn.getName();
addOperationDesc("getName() returned " + name);
passed = "dir/".equals(name);
} finally {
conn.close();
}
} catch (Exception e) {
logUnexpectedExceptionDesc(e);
passed = false;
}
assertTrueWithLog("Tests getName() on an existing directory,and a connection url not ending with '/'", passed);
}