src/org/openstreetmap/josm/plugins/opendata/core/modules/ReadRemoteModuleInformationTask.java
protected String downloadModuleList(String site, ProgressMonitor monitor) {
        StringBuilder sb = new StringBuilder();
        try {
            // replace %<x> with empty string */
            String printsite = site.replaceAll("%<(.*)>", "");

            monitor.beginTask("");
            monitor.indeterminateSubTask(tr("Downloading module list from ''{0}''", printsite));

            URL url = new URL(printsite);
            synchronized (this) {
                connection = (HttpURLConnection) url.openConnection();
                connection.setRequestProperty("Cache-Control", "no-cache");
                connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString());
                connection.setRequestProperty("Host", url.getHost());
                connection.setRequestProperty("Accept-Charset", "utf-8");
            }
            try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"))) {
                String line;
                while ((line = in.readLine()) != null) {
                    sb.append(line).append("\n");
                }
                return sb.toString();
            }
        } catch (MalformedURLException e) {
            if (canceled) return null;
            e.printStackTrace();
            return null;
        } catch (IOException e) {
            if (canceled) return null;
            e.printStackTrace();
            return null;
        } finally {
            synchronized (this) {
                if (connection != null) {
                    connection.disconnect();
                }
                connection = null;
            }
            monitor.finishTask();
        }
    }
/**
     * Downloads the list from a remote location
     *
     * @param site the site URL
     * @param monitor a progress monitor
     * @return the downloaded list
     */
Downloads the list from a remote location

@param site the site URL
@param monitor a progress monitor
@return the downloaded list
Downloads the list from a remote location @param site the site URL @param monitor a progress monitor @return the downloaded list
protected String downloadModuleList(String site, ProgressMonitor monitor) {
        StringBuilder sb = new StringBuilder();
        try {
            String printsite = site.replaceAll("%<(.*)>", "");
            monitor.beginTask("");
            monitor.indeterminateSubTask(tr("Downloading module list from ''{0}''", printsite));
            URL url = new URL(printsite);
            synchronized (this) {
                connection = (HttpURLConnection) url.openConnection();
                connection.setRequestProperty("Cache-Control", "no-cache");
                connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString());
                connection.setRequestProperty("Host", url.getHost());
                connection.setRequestProperty("Accept-Charset", "utf-8");
            }
            try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"))) {
                String line;
                while ((line = in.readLine()) != null) {
                    sb.append(line).append("\n");
                }
                return sb.toString();
            }
        } catch (MalformedURLException e) {
            if (canceled) return null;
            e.printStackTrace();
            return null;
        } catch (IOException e) {
            if (canceled) return null;
            e.printStackTrace();
            return null;
        } finally {
            synchronized (this) {
                if (connection != null) {
                    connection.disconnect();
                }
                connection = null;
            }
            monitor.finishTask();
        }
    }
protected String downloadModuleList ( String site , ProgressMonitor monitor ) { StringBuilder sb = new StringBuilder ( ) ; try { String printsite = site . replaceAll ( "%<(.*)>" , "" ) ; monitor . beginTask ( "" ) ; monitor . indeterminateSubTask ( tr ( "Downloading module list from ''{0}''" , printsite ) ) ; URL url = new URL ( printsite ) ; synchronized ( this ) { connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . setRequestProperty ( "Cache-Control" , "no-cache" ) ; connection . setRequestProperty ( "User-Agent" , Version . getInstance ( ) . getAgentString ( ) ) ; connection . setRequestProperty ( "Host" , url . getHost ( ) ) ; connection . setRequestProperty ( "Accept-Charset" , "utf-8" ) ; } try ( BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ( ) , "UTF-8" ) ) ) { String line ; while ( ( line = in . readLine ( ) ) != null ) { sb . append ( line ) . append ( "\n" ) ; } return sb . toString ( ) ; } } catch ( MalformedURLException e ) { if ( canceled ) return null ; e . printStackTrace ( ) ; return null ; } catch ( IOException e ) { if ( canceled ) return null ; e . printStackTrace ( ) ; return null ; } finally { synchronized ( this ) { if ( connection != null ) { connection . disconnect ( ) ; } connection = null ; } monitor . finishTask ( ) ; } }
Downloads the list from a remote location
Downloads the list from a remote location
// replace %<x> with empty string */
