O
Ouabaine
Hello,
I have a very strange problem here. I have found the solution, but I would
like to know what is happening.
I load a file from a JAR file, using the following code :
InputStream stream=this.getClass().getResourceAsStream(name);
if (stream!=null)
{
int size=stream.available();
byte data[]=new byte[size];
stream.read(data);
}
stream.available() returns the correct size, the size of the file in the jar
file (0x1610E).
But the above code does not work! Only the first 0x3111 bytes of the stream
are read, the rest of the array is still 0!
But it works if I do the following code !
int c;
for (c=0; c<size; c++)
{
data[c]=(byte)stream.read();
}
Could it be that the stream cannot handle such a massive data output at
once?
Have you got any idea about this?
Thanks!
I have a very strange problem here. I have found the solution, but I would
like to know what is happening.
I load a file from a JAR file, using the following code :
InputStream stream=this.getClass().getResourceAsStream(name);
if (stream!=null)
{
int size=stream.available();
byte data[]=new byte[size];
stream.read(data);
}
stream.available() returns the correct size, the size of the file in the jar
file (0x1610E).
But the above code does not work! Only the first 0x3111 bytes of the stream
are read, the rest of the array is still 0!
But it works if I do the following code !
int c;
for (c=0; c<size; c++)
{
data[c]=(byte)stream.read();
}
Could it be that the stream cannot handle such a massive data output at
once?
Have you got any idea about this?
Thanks!