*/
public boolean doPlayerPrefetch() {
// Has the data already been prefetched?
if( ! prefetchNeeded ) return true;
DataInputStream in = null;
byte[] b;
try {
// Create an input stream
in = new DataInputStream(
new PullSourceInputStream(stream) );
// Get the length
long length = stream.getContentLength();
if( length != SourceStream.LENGTH_UNKNOWN ) {
// Load the entire text file into a byte array
b = new byte[(int)length];
in.readFully(b,0,(int)length);
} else {
System.err.println(
"Unknown content length while reading data");
postEvent(
new ResourceUnavailableEvent(this,
"Could not get content length from data stream") );
return false;
}
}
catch(EOFException e) {
System.err.println("Unexpected EOF while reading data");
postEvent(
new ResourceUnavailableEvent(this,
"Unexpected EOF occurred while reading data stream") );
return false;
}
catch(IOException e) {
System.err.println("I/O Error reading data");
postEvent(
new ResourceUnavailableEvent(this,
"I/O error occurred while reading data stream") );
return false;
}
finally {
try { in.close(); } catch(Exception e) {}
}
// Convert the byte array to a String and set the
// TickerTape message
tape.setMessage( new String(b,0,b.length) );