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)
54 throws FileNotFoundException {
55 String templateName = "";
56 Properties migrationProperties = new Properties();
57
58 try (InputStream is = new FileInputStream(templatePath)) {
59 migrationProperties.load(is);
60 templateName = migrationProperties.getProperty(templateProperty);
61 } catch (FileNotFoundException e) {
62 throw e;
63 } catch (Exception e) {
64 log.error("", e);
65 }
66
67 return templateName;
68 }
69
70 }