All pastes #486972 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-14 05:23 UTC
rendered paste body
import java.io.DataInputStream;
import java.io.IOException;
import java.net.URL;

public class WorldList {
	public World[] worlds;

	private WorldList() {
	}

//World list binary format: http://www.runescape.com/slr.ws?order=LPWM

	public static WorldList newInstance(String worldListAddress) throws IOException {
		WorldList worldList = new WorldList();
		DataInputStream in = new DataInputStream(new URL(worldListAddress).openStream());
		in.skip(4);
		worldList.worlds = new World[in.readShort()];
		for(int i = 0; i < worldList.worlds.length; i++) {
			int j = in.readShort();
			StringBuffer prefix = new StringBuffer();
			byte b = -1;
			while((b = in.readByte()) != 0)
				prefix.append((char)b);
			worldList.worlds[i] = new World(prefix.toString(), j & 0x7FFF, in.readShort(), (j & 0x8000) != 0);
		}
		return worldList;
	}

}