05-09-2011 10:54 PM
Hi...
I'm already trying to use the code but i got IOException (File system error (1000))
Here is the code
try {
fileGroup = new TagGroup(FileConnectionLibrary.openFile("file:///S DCard/BlackBerry/system/media/thumbs116x116.dat")
, FileConnectionLibrary.ISlength);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this is my FileConnectionLibrary
public class FileConnectionLibrary{
private static FileConnection fconn;
private static InputStream iS;
private static byte[] data;
public static int ISlength;
public static InputStream openFile(String path)
{
InputStream result = null;
try {
fconn = (FileConnection)Connector.open(path, Connector.READ_WRITE);
if (fconn.exists())
{
iS = fconn.openInputStream();
result = iS;
data = IOUtilities.streamToBytes(iS);
ISlength = data.length;
}
} catch (IOException e) {
ISlength = 0;
}
finally {
try {
iS.close();
fconn.close();
} catch (IOException e) {}
}
return result;
}
can you help me, please?
05-11-2011 03:40 PM
Can you trace to see where it is coming from since it seems like a very generic exception.
Also you can simply call fileSize() on FileConnection to get the file size.
05-11-2011 10:21 PM
hi... the problem is lying in Tag Class
If I'm using this code in TagGroug
DataInputStream br = new DataInputStream(st);
int smallEdnian = 1570;
if (br.readShort() != smallEndian) //8710 for big-endian { //Not valid dataBase return; }
it's not valid database
but if i'm using big-endian (8710), my error is in Tag Class
public Tag(DataInputStream br) throws IOException
{
Reserved1 = TagGroup.reverseEndian(br.readShort());
PathLength = TagGroup.reverseEndian(br.readInt());
NameLength = TagGroup.reverseEndian(br.readInt());
DataLength = TagGroup.reverseEndian(br.readInt());
Reserved2 = TagGroup.reverseEndian(br.readInt());
Reserved3 = TagGroup.reverseEndian(br.readInt());
Reserved4 = TagGroup.reverseEndian(br.readInt());
int b = br.read(); //Gap (0)
Path = new String(TagGroup.readChars(br, PathLength));
Name = new String(TagGroup.readChars(br, NameLength));
when accessing path, i got an error java.lang.OutOfMemoryError..
05-11-2011 11:24 PM
Hmm, I wonder if they updated the number. Need to check again.
Since it was demonstration code it didn't really take error checking into account.
05-12-2011 11:20 AM
I made a bunch of mistakes that I didn't catch (I don't know how I even got it to work) and fixed the code. It's posted the updated code to the same thread that the original code came from:
Let me know if you get any issues from that. Also, being that it's just demonstration code, you might want modify the code to skip the data and just take the names and paths. Calculate an offset at the time of tag creation, then when the image is necessary, read it in. I say this because when I tried to read the 480x480 thumbs (for testing purposes) I got OutOfMemory exceptions. I don't know how many images some people have but you never know what might happen. Also I stand corrected (can't edit previous post), pre-5.0 the thumbs were in PNG format, for the thumbnail files I checked (Storm2, 5.0) they where JPEGs. Just use EncodedImage and everything will be fine.
05-12-2011 09:52 PM
Thanx for the code,
The problem is i still got out of memory error...
But, when i'm debugging it, i can fet some of the image, but after that out of memory occured..
i've tried to call system.gc for everytime i instance a new tag class, but still got the problem...
Any solution for handle this error?
05-16-2011 12:51 AM
That's basically what I said in the second part of my previous post. You'll get out of memory exceptions. You need to come up with your own version that only loads what is visible on your image loader. This way you don't load (in my case) over 3500 480x480 images at the same time.