Ignore:
Timestamp:
2014-10-19T01:27:04+02:00 (10 years ago)
Author:
donvip
Message:

[josm_plugins] fix java 7 warnings / global usage of try-with-resource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/DatabaseParser.java

    r23190 r30738  
    11package org.openstreetmap.josm.plugins.czechaddress.parser;
    22
    3 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.*;
    43import java.io.BufferedOutputStream;
    54import java.io.File;
     
    98import java.net.HttpURLConnection;
    109import java.net.URL;
     10
    1111import org.openstreetmap.josm.Main;
    1212import org.openstreetmap.josm.plugins.czechaddress.DatabaseLoadException;
     13import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Database;
    1314
    1415/**
     
    109110                        "Požadavek na server selhal, číslo chyby: " + String.valueOf( con.getResponseCode() ));
    110111
    111             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(getDatabasePath()));
    112 
    113             int total = 0, count;
    114             byte[] buffer = new byte[1024*512];
    115             while ((count = con.getInputStream().read(buffer)) >= 0) {
    116                 bos.write(buffer, 0, count);
    117                 total += count;
    118                 System.err.println("CzechAddress: MVČR database: " + String.valueOf(total/1024) + " kb downloaded.");
     112            try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(getDatabasePath()))) {
     113                    int total = 0, count;
     114                    byte[] buffer = new byte[1024*512];
     115                    while ((count = con.getInputStream().read(buffer)) >= 0) {
     116                        bos.write(buffer, 0, count);
     117                        total += count;
     118                        Main.error("CzechAddress: MVČR database: " + String.valueOf(total/1024) + " kb downloaded.");
     119                    }
    119120            }
    120 
    121             bos.close();
    122121
    123122            // Look for a detailed error message from the server
Note: See TracChangeset for help on using the changeset viewer.