I’m trying to make an applet loader for my game. Once downloaded, the 3 .jar files it needs are the correct size, but they don’t work. I opened them with a hex editor and found that some bytes are being changed to other bytes, seemingly at random. However, it isn’t random because if I delete the files and have them download again, the same incorrect bytes are in the same places! It’s really weird.
Here is the code.
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
int len = conn.getContentLength();
downloadStream = new ProgressBarInputStream(conn.getInputStream(), updatePanel.progressBar, len);
String filePath = gamePath + "/" + urlString.replace("http://mydomain.net/game/", "");
FileOutputStream out = new FileOutputStream(filePath);
int bytes = 0;
while (bytes < len) {
out.write(downloadStream.read());
bytes++;
}
out.close();
downloadStream.close();