Ignore:
Timestamp:
2007-07-17T20:48:52+02:00 (17 years ago)
Author:
frsantos
Message:

Don't use Plugin.copy() method, as it does it wrong

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ywms/src/org/openstreetmap/josm/plugins/ywms/Util.java

    r3575 r3612  
    246246        return new File(localPath);
    247247    }
     248   
     249        /**
     250         * Copies the ressource 'from' to the file in the plugin directory named 'to'.
     251         * @param from The source directory
     252         * @param to The destination directory
     253         * @throws FileNotFoundException
     254         * @throws IOException
     255         */
     256        public static void copy(String from, String to) throws FileNotFoundException, IOException {
     257                File pluginDir = new File(getPluginDir());
     258                if (!pluginDir.exists())
     259                        pluginDir.mkdirs();
     260        FileOutputStream out = new FileOutputStream(getPluginDir()+to);
     261        InputStream in = Util.class.getResourceAsStream(from);
     262        byte[] buffer = new byte[8192];
     263        for(int len = in.read(buffer); len > 0; len = in.read(buffer))
     264                out.write(buffer, 0, len);
     265        in.close();
     266        out.close();
     267    }
    248268}
  • applications/editors/josm/plugins/ywms/src/org/openstreetmap/josm/plugins/ywms/YWMSPlugin.java

    r3574 r3612  
    8686                try
    8787                {
    88                         copy("/resources/ymap.html", "ymap.html");
    89                         copy("/resources/config.html", "config.html");
     88                        Util.copy("/resources/ymap.html", "ymap.html");
     89                        Util.copy("/resources/config.html", "config.html");
    9090                        restartServer();
    9191                }
Note: See TracChangeset for help on using the changeset viewer.