001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.io; 003 004import java.io.File; 005import java.io.FileNotFoundException; 006import java.io.FileOutputStream; 007import java.io.IOException; 008import java.io.OutputStream; 009 010import org.apache.tools.bzip2.CBZip2OutputStream; 011import org.openstreetmap.josm.tools.Utils; 012 013public class OsmBzip2Exporter extends OsmExporter { 014 015 /** 016 * Constructs a new {@code OsmBzip2Exporter}. 017 */ 018 public OsmBzip2Exporter() { 019 super(OsmBzip2Importer.FILE_FILTER); 020 } 021 022 @Override 023 protected OutputStream getOutputStream(File file) throws FileNotFoundException, IOException { 024 OutputStream out = new FileOutputStream(file); 025 try { 026 out.write('B'); 027 out.write('Z'); 028 return new CBZip2OutputStream(out); 029 } catch (IOException e) { 030 Utils.close(out); 031 throw e; 032 } 033 } 034}