Changeset 34479 in osm


Ignore:
Timestamp:
2018-08-15T14:05:08+02:00 (6 years ago)
Author:
donvip
Message:

fix initialization

Location:
applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteDefinition.java

    r34477 r34479  
    88import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    99import org.openstreetmap.josm.data.osm.search.SearchParseError;
     10import org.openstreetmap.josm.tools.Logging;
    1011
    1112public class RouteDefinition {
     
    2425        } catch (SearchParseError e) {
    2526            match = new SearchCompiler.Never();
    26             e.printStackTrace();
     27            Logging.error(e);
    2728        }
    2829    }
  • applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java

    r34477 r34479  
    44import java.io.File;
    55import java.io.FileInputStream;
    6 import java.io.FileOutputStream;
    76import java.io.IOException;
    87import java.io.InputStream;
    9 import java.io.OutputStream;
     8import java.nio.file.Files;
    109import java.util.ArrayList;
    1110import java.util.List;
     
    3736        MainApplication.getLayerManager().addLayerChangeListener(this);
    3837
    39         File routesFile = new File(getPluginDirs().getUserDataDirectory(false), "routes.xml");
     38        File routesFile = new File(getPluginDirs().getUserDataDirectory(true), "routes.xml");
    4039        if (!routesFile.exists()) {
    4140            Logging.info("File with route definitions doesn't exist, using default");
    42 
    43             try {
    44                 routesFile.getParentFile().mkdir();
    45                 try (
    46                         OutputStream outputStream = new FileOutputStream(routesFile);
    47                         InputStream inputStream = Routes.class.getResourceAsStream("routes.xml");
    48                         ) {
    49                     byte[] b = new byte[512];
    50                     int read;
    51                     while ((read = inputStream.read(b)) != -1) {
    52                         outputStream.write(b, 0, read);
    53                     }
    54                 }
     41            try (InputStream inputStream = getClass().getResourceAsStream(
     42                    "/resources/org/openstreetmap/josm/plugins/routes/xml/routes.xml");
     43                    ) {
     44                Files.copy(inputStream, routesFile.toPath());
    5545            } catch (IOException e) {
    5646                Logging.error(e);
Note: See TracChangeset for help on using the changeset viewer.