Argument 'address' is the string "CepVizyonVersionFile", and after Connector.openDataInputStream(address)
the program throws an exception with message:
no ' : ' in URL.
What format should address be in?
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 has an explanation of the format:
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.
The {target} is normally some kind of network address.
Any {parms} are formed as a series of equates of the form ";x=y". Example: ";type=a".
and the supported schemes are listed as well:
comm
socket
udp
sms
mms
http
https
tls or ssl
Bluetooth Serial Port Profile
Since you want a file, you'll need to take a look at the package documentation for javax.microedition.io.file
The format of the input string used to access a FileConnection through Connector.open() must follow the format for a fully qualified, absolute path file name as described in the file URL format as part of IETF RFCs 1738 & 2396. That RFC dictates that a file URL takes the form:
file://<host>/<path>