参数'address'是字符串“CepVizyonVersionFile”,在Connector.openDataInputStream(address)
之后,程序抛出一条带有消息的异常:
网址中没有':'。
应该采用什么格式?
public void saveLocal(String fileString, String address) {
try {
DataOutputStream fos = Connector.openDataOutputStream(address); //openFileOutput(address);
fos.write(fileString.getBytes());
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String readLocal(String address, int lenght) {
byte[] buffer = new byte[lenght];
byte[] buffer2;
String str = new String();
try {
DataInputStream fis = Connector.openDataInputStream(address);
int lnght = fis.read(buffer);
buffer2 = new byte[lnght];
fis.close();
for (int i = 0; i < lnght; i++)
buffer2[i] = buffer[i];
str = new String(buffer2);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
答案 0 :(得分:1)
你把文件放在哪里?
如果它在媒体卡上,你的地址应该是这样的:“file:/// SDCard /”+ yourfilename。
答案 1 :(得分:0)
Connector的BlackBerry API文档说明了格式:
描述目标的参数字符串应符合RFC 2396中描述的URL格式。这采用一般形式: {方案}:[{目标}] [{PARMS}] 其中{scheme}是协议的名称,例如http。
{target}通常是某种网络地址。
任何{parms}都形成为“; x = y”形式的一系列等式。示例:“; type = a”。
并列出了支持的方案:
COMM
插座
UDP
短信
MMS
HTTP
HTTPS
tls或ssl
蓝牙串口配置文件
由于您需要文件,因此您需要查看javax.microedition.io.file
的软件包文档用于通过Connector.open()访问FileConnection的输入字符串的格式必须遵循完全限定的绝对路径文件名的格式,如文件URL格式中所述,作为IETF RFC 1738&amp; 2396.该RFC规定文件URL采用以下形式:
file://<host>/<path>