Changeset 5874 in josm for trunk/src/org/openstreetmap/josm/io/OsmExporter.java
- Timestamp:
- 2013-04-16T19:57:43+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r5361 r5874 21 21 import org.openstreetmap.josm.gui.layer.Layer; 22 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 import org.openstreetmap.josm.tools.Utils; 23 24 24 25 public class OsmExporter extends FileExporter { … … 64 65 if (file.exists()) { 65 66 tmpFile = new File(file.getPath() + "~"); 66 copy(file, tmpFile);67 Utils.copyFile(file, tmpFile); 67 68 } 68 69 … … 75 76 try { 76 77 w.writeLayer(layer); 77 w.close();78 78 } finally { 79 Utils.close(w); 79 80 layer.data.getReadLock().unlock(); 80 81 } … … 99 100 // be deleted. So, restore the backup if we made one. 100 101 if (tmpFile != null && tmpFile.exists()) { 101 copy(tmpFile, file);102 Utils.copyFile(tmpFile, file); 102 103 } 103 104 } catch (IOException e2) { … … 112 113 } 113 114 } 114 115 private void copy(File src, File dst) throws IOException {116 FileInputStream srcStream;117 FileOutputStream dstStream;118 try {119 srcStream = new FileInputStream(src);120 dstStream = new FileOutputStream(dst);121 } catch (FileNotFoundException e) {122 JOptionPane.showMessageDialog(Main.parent, tr("Could not back up file. Exception is: {0}", e123 .getMessage()), tr("Error"), JOptionPane.ERROR_MESSAGE);124 return;125 }126 byte buf[] = new byte[1 << 16];127 int len;128 while ((len = srcStream.read(buf)) != -1) {129 dstStream.write(buf, 0, len);130 }131 srcStream.close();132 dstStream.close();133 }134 135 115 }
Note:
See TracChangeset
for help on using the changeset viewer.