Hallo an alle Java-Tekkis!

Hat jemand schon mal versucht, das planet.osm.bz2 direkt in Java einzulesen? Bei mir bricht das Teil grundsätzlich nach 900.000 Bytes zusammen. Nix Fehlermeldung - einfach "fertig".

Gruß, Carsten.

PS:
Code in etwa so (Schnellschuss):


public static void main(String[] args) throws Exception {
  URL url = new URL(
    "http://ftp.ecki-netz.de/osm/planet-latest.osm.bz2";);
  InputStream is = url.openStream();
  BZip2CompressorInputStream bz2is = new BZip2CompressorInputStream(is);
  OutputStream os = new FileOutputStream("planet.osm");
  byte[] buf = new byte[1024];
  int bytesRead = bz2is.read(buf);
  int i = 0;
  // Wir wollen hier nicht alles lesen, 10000 loops reichen.
  while (i++ < 10000 && bytesRead >= 0) {
    os.write(buf, 0, bytesRead);
    bytesRead = bz2is.read(buf);
  }
  bz2is.close();
  os.close();
}


_______________________________________________
Talk-de mailing list
Talk-de@openstreetmap.org
http://lists.openstreetmap.org/listinfo/talk-de

Antwort per Email an