English 中文(简体)
Save and 改为 file withstream on BlackBerry
原标题:Save and read file with stream on BlackBerry

地址是“CepVizyonVersionFile”,在Connector. openDataInputStream(address)之后,该方案将发出一个例外信息:

页: 1

应采取何种形式?

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;
}
最佳回答

The BlackBerry API documentation for Connector对格式作了解释:

The parameter string that describes the target should conform to the URL format as described in RFC 2396. This takes the general form: {scheme}:[{target}][{parms}] where {scheme} is the name of a protocol such as http.

{具体目标}通常是某种网络地址。

任何{门槛值}均构成一系列“;x=y”的等值。 例:“;类型=a”。

此外,还列出了支助计划:

comm
socket
udp
sms
mms
http
https
tls or ssl
Bluetooth Serial Port Profile

由于你想要档案,你需要看一下

用于通过“联接”获取文档Connection的信息输入格式必须遵循“URL”文件格式中描述的完全合格的绝对路径名称格式,作为ETF RFCs 1738 &的一部分;2396。 RFC规定,URL档案采取下列形式:

file http://<host>/<path>

问题回答

您的档案在哪里? 如果在媒体卡上,你的地址就好像是:“文件http:///SDCard/”+yourfilename。





相关问题
How does AlertListener work on Blackberry API 5.0?

Does the AlertListener interface works globally on all alerts on the blackberry device, or does it only work with alerts generated by your application? In other words, can I use this interface to ...

How to buffer audio in Blackberry?

I need to learn how to buffer audio stream from a remote server in Blackberry. There is a sample buffered playback app with Blackberry api but can you tell what url may I use to test the application?

Blackberry push notification implementation

How does one implement a push notification for a blackberry app? I heard that in order to do so I need to purchase a Blackberry Enterprise Server which costs me 1400 per year. Is this true? Where is ...

热门标签