Ignore:
Timestamp:
2013-04-16T19:57:43+02:00 (11 years ago)
Author:
Don-vip
Message:

see #8570, #7406 - I/O refactorization:

  • Move different file copy functions to Utils.copyFile (to be replaced later by Files.copy when switching to Java 7)
  • Replace all Utils.close(XXX) by Utils.close(Closeable) -> impacted plugins: commandline, mirrored_download, opendata, piclayer
  • Add new Utils.close(ZipFile)
  • Use of Utils.close almost everywhere
  • Javadoc fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/Plugin.java

    r5836 r5874  
    1515import org.openstreetmap.josm.gui.download.DownloadSelection;
    1616import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     17import org.openstreetmap.josm.tools.Utils;
    1718
    1819/**
     
    110111            pluginDir.mkdirs();
    111112        }
    112         FileOutputStream out = new FileOutputStream(new File(pluginDirName, to));
    113         InputStream in = getClass().getResourceAsStream(from);
    114         byte[] buffer = new byte[8192];
    115         for(int len = in.read(buffer); len > 0; len = in.read(buffer)) {
    116             out.write(buffer, 0, len);
     113        FileOutputStream out = null;
     114        InputStream in = null;
     115        try {
     116            out = new FileOutputStream(new File(pluginDirName, to));
     117            in = getClass().getResourceAsStream(from);
     118            byte[] buffer = new byte[8192];
     119            for(int len = in.read(buffer); len > 0; len = in.read(buffer)) {
     120                out.write(buffer, 0, len);
     121            }
     122        } finally {
     123            Utils.close(in);
     124            Utils.close(out);
    117125        }
    118         in.close();
    119         out.close();
    120126    }
    121127
Note: See TracChangeset for help on using the changeset viewer.