ZipException: unknown compression method

Kai008

Erfahrenes Mitglied
Mir wird bei meinen Programm ab und zu folgende Exception geschmissen:

Code:
java.util.zip.ZipException: unknown compression method
	at java.util.zip.InflaterInputStream.read(Unknown Source)
	at java.io.BufferedInputStream.fill(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	at sun.awt.image.PNGImageDecoder.produceImage(Unknown Source)
	at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
	at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
	at sun.awt.image.ImageFetcher.run(Unknown Source)

Ich schätze, in ca. 60 % aller Fälle. Laut Sun Bugtracker kommt der Fehler daher, dass der InflaterInputStream nicht komplett gelesen wurde.
Aber darauf habe ich ja gar keinen Zugriff und kann deshalb nichts machen, oder?

Hier mein Code:

Java:
private static void loadPlanetsFromServer(Map<Point, SectorPanel> sectorPanelMap, Container spaceViewPanel,
		Socket socket)
{
	String commandText = null;
	MediaTracker tracker = new MediaTracker(new Container());
	do
	{
		Command cmd = Command.read(socket); 
		commandText = cmd.getCommand();

		if(commandText.equals(Command.COMMAND_SPACE_VIEW_NEXT_PART))
		{
			int sectorX = Integer.parseInt(cmd.getParameter(0));
			int sectorY = Integer.parseInt(cmd.getParameter(1));
			int xOnSectorPanel = Integer.parseInt(cmd.getParameter(2));
			int yOnSectorPanel = Integer.parseInt(cmd.getParameter(3));
			int width = Integer.parseInt(cmd.getParameter(4));
			int height = Integer.parseInt(cmd.getParameter(5));
			String planetImageInHex = cmd.getParameter(6);

			byte[] b = parseHexToByte(planetImageInHex);
			Image planetImage = Toolkit.getDefaultToolkit().createImage(b);
			
			tracker.addImage(planetImage, 0);
			try
			{
				tracker.waitForID(0);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
			
			Planet planet = new Planet();
			planet.setBounds(xOnSectorPanel, yOnSectorPanel, width, height);
			planet.setIcon(new ImageIcon(planetImage));
			
			Point p = new Point(sectorX, sectorY);
			SectorPanel sectorPanel = sectorPanelMap.get(p);
			if(sectorPanelMap.get(new Point(sectorX, sectorY)) == null)
			{
				sectorPanel = new SectorPanel();
				sectorPanel.setBounds(sectorX, sectorY, 1000, 1000);
				spaceViewPanel.add(sectorPanel);
				sectorPanelMap.put(p, sectorPanel);
			}
			sectorPanel.add(planet);
		}
	}
	while(!commandText.equals(Command.COMMAND_SPACE_VIEW_FINISH));
}

Der Fehler tritt wohl beim asymetrischen Laden des Bildes nach toolkit.createImage(byte[]) auf.
 
Zurück