Reputation: 536
I am new in Blackberry. I want to get all images from particular path like "file:///SDCard/BlackBerry/pictures/". I have searched and found following code..
public static byte[] getBytesFromFile(String filename) throws IOException {
FileConnection fconn = null;
InputStream is = null;
try {
fconn = (FileConnection) Connector.open(filename, Connector.READ);
is = fconn.openInputStream();
return IOUtilities.streamToBytes(is);
} finally {
if (is != null) {
is.close();
}
if (fconn != null) {
fconn.close();
}
}
}
I have implemented this but i am getting Not a file exception. Is there any other way ?
If any one has idea, please help me as soon as possible..
Upvotes: 1
Views: 97
Reputation: 2650
Since you are new to Blackberry, I recommend that you review the BlackBerry micro-site for the Java developer, which you will find here:
Included on that page, there are links to various things, included the API documentation, which you will find (for OS 7.1) here:
You are using the FileConnection API, so look for the FileConnection class and see what methods are available - I think the one you want is list().
Finally you might find this sample code, that searches through a directory, useful:
Create-a-file-selection-popup-screen
Good luck.
Upvotes: 2