I’ve been doing some small experiments with applets and I’ve run into some trouble. I’m sure there must be a really simple solution to this.
I have a binary file on a webserver and am using the following code to access it from an applet:
url = new URL( getDocumentBase(), getParameter( “filename” ) );
InputStream i = url.openStream();
// … Read bytes and close stream
The problem is the data I receive is scrambled. I’m not sure exactly how the scrambling is done but I assume it’s being “cooked” (inappropriate ascii cr/lf conversion).
The file is not scrambled when I download it using a web browser so there’s no problem with the source. The content-type is “audio/mod”. My guess is java doesn’t understand this and is treating it as ascii.
I have tried getting a URLConnection and manually setting the “content-type” request property to “application/octet-stream” but that didn’t help. Maybe this is only used for sending data?
Hope someone can help!
Martin