Search in sources :

Example 1 with StatsSaveException

use of org.openstreetmap.osmosis.tagtransform.StatsSaveException in project osmosis by openstreetmap.

the class TransformHelper method complete.

@Override
public void complete() {
    if (statsFile != null && !statsFile.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        builder.append(configFile);
        builder.append("\n\n");
        for (Translation t : translations) {
            t.outputStats(builder, "");
        }
        Writer writer = null;
        try {
            writer = new FileWriter(new File(statsFile));
            writer.write(builder.toString());
        } catch (IOException e) {
            throw new StatsSaveException("Failed to save stats: " + e.getLocalizedMessage(), e);
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    logger.log(Level.WARNING, "Unable to close stats file " + statsFile + ".", e);
                }
            }
        }
    }
    sink.complete();
}
Also used : Translation(org.openstreetmap.osmosis.tagtransform.Translation) FileWriter(java.io.FileWriter) IOException(java.io.IOException) StatsSaveException(org.openstreetmap.osmosis.tagtransform.StatsSaveException) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Aggregations

File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 StatsSaveException (org.openstreetmap.osmosis.tagtransform.StatsSaveException)1 Translation (org.openstreetmap.osmosis.tagtransform.Translation)1