blob: bbdf6539ed9876751ac14b8a9c2942bfeb61dc3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package org.navitproject.navit;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
class NavitUtils {
static void removeFileIfExists(String source) {
File file = new File(source);
if (!file.exists()) {
return;
}
file.delete();
}
static void copyFileIfExists(String source, String destination) throws IOException {
File file = new File(source);
if (!file.exists()) {
return;
}
FileInputStream is = null;
FileOutputStream os = null;
try {
is = new FileInputStream(source);
os = new FileOutputStream(destination);
int len;
byte[] buffer = new byte[1024];
while ((len = is.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
} finally {
/* Close the FileStreams to prevent Resource leaks */
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
}
}
}
|