Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
EggieOGeggie
Posts: 12
Registered: ‎11-19-2010
My Device: Not Specified

Need recommendation for random access reading, sequential writing file i/o

There seem to be a few classes for file i/o, and I'm not sure which I should be using. I need to:

  1. Randomly access a file for reading
  2. Sequentially write to another file

Both of these files are binary, and the data will be read and written with byte arrays. I saw that the answer to a similar question was http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/io/Seekable.html but I'm a bit of a Java noob, and don't quite know how to use that, if I even should be using it. Thanks.

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Need recommendation for random access reading, sequential writing file i/o

I'm not quite sure about #2 but #1 is possible on OS 5.0 and higher.

 

There was a discussion about it here: http://supportforums.blackberry.com/t5/Java-Development/Can-we-read-and-write-to-a-file-at-the-same-...

 

It has a example I wrote up. Seekables seem only like you can use it with FileConnection but never tried anything else out myself.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Contributor
EggieOGeggie
Posts: 12
Registered: ‎11-19-2010
My Device: Not Specified

Re: Need recommendation for random access reading, sequential writing file i/o

Well, right now it's looking like it won't be possible. I don't know what's going on, I tried opening a file using the prescribed method (Connector.open(sPath)) but (fcon instanceof Seekable) comes back false. That's pretty strange, since the file I'm opening is using the BlackBerry backbone file system. I guess I'm just going to have to design my whole app to just be sequential. Fail

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Need recommendation for random access reading, sequential writing file i/o

After Connector.open(sPath) call some function like openOutputStream and than try (ostm instanceof Seekable).

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.