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.FileNotFoundException;
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.io.OutputStream;
23 import java.nio.file.Files;
24 import java.nio.file.Path;
25 import java.util.Properties;
26
27 import org.apache.ibatis.logging.Log;
28 import org.apache.ibatis.logging.LogFactory;
29
30
31
32
33 @Deprecated
34 public class ExternalResources {
35
36 private static final Log log = LogFactory.getLog(ExternalResources.class);
37
38 private ExternalResources() {
39
40 }
41
42 public static void copyExternalResource(File sourceFile, File destFile) throws IOException {
43 if (!destFile.exists()) {
44 destFile.createNewFile();
45 }
46
47 try (InputStream source = Files.newInputStream(sourceFile.toPath());
48 OutputStream destination = Files.newOutputStream(destFile.toPath())) {
49 source.transferTo(destination);
50 }
51
52 }
53
54 public static String getConfiguredTemplate(String templatePath, String templateProperty)
55 throws FileNotFoundException {
56 String templateName = "";
57 Properties migrationProperties = new Properties();
58
59 try (InputStream is = Files.newInputStream(Path.of(templatePath))) {
60 migrationProperties.load(is);
61 templateName = migrationProperties.getProperty(templateProperty);
62 } catch (FileNotFoundException e) {
63 throw e;
64 } catch (Exception e) {
65 log.error("", e);
66 }
67
68 return templateName;
69 }
70
71 }