1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.io;
17
18 import java.io.File;
19 import java.io.FileInputStream;
20 import java.io.FileNotFoundException;
21 import java.io.FileOutputStream;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.util.Properties;
25
26 import org.apache.ibatis.logging.Log;
27 import org.apache.ibatis.logging.LogFactory;
28
29
30
31
32 @Deprecated
33 public class ExternalResources {
34
35 private static final Log log = LogFactory.getLog(ExternalResources.class);
36
37 private ExternalResources() {
38
39 }
40
41 public static void copyExternalResource(File sourceFile, File destFile) throws IOException {
42 if (!destFile.exists()) {
43 destFile.createNewFile();
44 }
45
46 try (FileInputStream source = new FileInputStream(sourceFile);
47 FileOutputStream destination = new FileOutputStream(destFile)) {
48 destination.getChannel().transferFrom(source.getChannel(), 0, source.getChannel().size());
49 }
50
51 }
52
53 public static String getConfiguredTemplate(String templatePath, String templateProperty) throws FileNotFoundException {
54 String templateName = "";
55 Properties migrationProperties = new Properties();
56
57 try (InputStream is = new FileInputStream(templatePath)) {
58 migrationProperties.load(is);
59 templateName = migrationProperties.getProperty(templateProperty);
60 } catch (FileNotFoundException e) {
61 throw e;
62 } catch (Exception e) {
63 log.error("", e);
64 }
65
66 return templateName;
67 }
68
69 }