OmegaT の背景に画像を表示します。
support OmegaT 4.1.1b
@@ -24,6 +24,7 @@ | ||
24 | 24 | import java.io.IOException; |
25 | 25 | import java.io.Writer; |
26 | 26 | import java.net.URISyntaxException; |
27 | +import java.nio.charset.StandardCharsets; | |
27 | 28 | import java.util.ArrayList; |
28 | 29 | import java.util.Comparator; |
29 | 30 | import java.util.HashMap; |
@@ -66,7 +67,7 @@ | ||
66 | 67 | public MoeConfig(File file) throws IOException { |
67 | 68 | this.file = file; |
68 | 69 | if (file.isFile()) { |
69 | - String script = FileUtil.readTextFile(file); // as UTF-8 | |
70 | + String script = MoeUtil.readTextFile(file, StandardCharsets.UTF_8); | |
70 | 71 | config = createBindedConfigSlurper().parse(script); |
71 | 72 | addAll(sortedConfigs, config); |
72 | 73 | } |
@@ -9,7 +9,7 @@ | ||
9 | 9 | import groovy.util.ConfigObject; |
10 | 10 | import java.util.Set; |
11 | 11 | import org.omegat.core.Core; |
12 | -import org.omegat.util.StaticUtils; | |
12 | +import org.omegat.util.StringUtil; | |
13 | 13 | |
14 | 14 | /** |
15 | 15 | * |
@@ -34,8 +34,8 @@ | ||
34 | 34 | } |
35 | 35 | |
36 | 36 | private void initUI() { |
37 | - this.setTitle(StaticUtils.format(L10n.get(L10n.Key.DIALOG_TITLE), | |
38 | - L10n.get(L10n.Key.CURRENT_VERSION))); | |
37 | + this.setTitle(StringUtil.format(L10n.get(L10n.Key.DIALOG_TITLE), | |
38 | + L10n.get(L10n.Key.CURRENT_VERSION))); | |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -21,9 +21,10 @@ | ||
21 | 21 | import java.io.FileInputStream; |
22 | 22 | import java.io.IOException; |
23 | 23 | import java.io.InputStreamReader; |
24 | -import java.io.StringWriter; | |
25 | 24 | import java.net.URISyntaxException; |
26 | 25 | import java.net.URL; |
26 | +import java.nio.charset.Charset; | |
27 | +import java.nio.charset.StandardCharsets; | |
27 | 28 | import java.security.CodeSource; |
28 | 29 | import java.util.ArrayList; |
29 | 30 | import java.util.Collections; |
@@ -30,9 +31,7 @@ | ||
30 | 31 | import java.util.List; |
31 | 32 | import java.util.regex.Matcher; |
32 | 33 | import java.util.regex.Pattern; |
33 | -import org.omegat.util.LFileCopy; | |
34 | 34 | import org.omegat.util.Log; |
35 | -import org.omegat.util.OConsts; | |
36 | 35 | import org.omegat.util.StaticUtils; |
37 | 36 | |
38 | 37 | /** |
@@ -85,7 +84,7 @@ | ||
85 | 84 | |
86 | 85 | } else if (fileName.endsWith(".webloc")) { |
87 | 86 | // .webloc is Mac OS X Website Location file for safari |
88 | - String text = readTextFile(file, OConsts.UTF8); | |
87 | + String text = readTextFile(file, StandardCharsets.UTF_8); | |
89 | 88 | Matcher matcher = RE_URL_IN_WEBLOC.matcher(text); |
90 | 89 | if (matcher.find()) { |
91 | 90 | return new URL(matcher.group(1)); |
@@ -103,14 +102,22 @@ | ||
103 | 102 | } |
104 | 103 | |
105 | 104 | /** |
106 | - * Read file as platform dependent encoding text. | |
105 | + * Read file as specified encoding text. | |
107 | 106 | */ |
108 | 107 | public static String readTextFile(File file, String encoding) throws IOException { |
108 | + Charset charset = Charset.forName(encoding); | |
109 | + return readTextFile(file, charset); | |
110 | + } | |
111 | + | |
112 | + /** | |
113 | + * Read file as specified encoding text. | |
114 | + */ | |
115 | + public static String readTextFile(File file, Charset encoding) throws IOException { | |
109 | 116 | BufferedReader rd = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding)); |
110 | 117 | try { |
111 | - StringWriter out = new StringWriter(); | |
112 | - LFileCopy.copy(rd, out); | |
113 | - return out.toString(); | |
118 | + char[] cbuf = new char[(int) file.length()]; | |
119 | + rd.read(cbuf); | |
120 | + return String.valueOf(cbuf); | |
114 | 121 | } finally { |
115 | 122 | rd.close(); |
116 | 123 | } |
@@ -21,7 +21,7 @@ | ||
21 | 21 | import jp.osdn.users.yutang.omegat.plugin.moenizer.L10n; |
22 | 22 | import jp.osdn.users.yutang.omegat.plugin.moenizer.ThemeChanger; |
23 | 23 | import org.omegat.core.Core; |
24 | -import org.omegat.util.StaticUtils; | |
24 | +import org.omegat.util.StringUtil; | |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * |
@@ -46,8 +46,8 @@ | ||
46 | 46 | } |
47 | 47 | |
48 | 48 | private void initUI() { |
49 | - this.setTitle(StaticUtils.format(L10n.get(L10n.Key.DIALOG_TITLE), | |
50 | - L10n.get(L10n.Key.CURRENT_VERSION))); | |
49 | + this.setTitle(StringUtil.format(L10n.get(L10n.Key.DIALOG_TITLE), | |
50 | + L10n.get(L10n.Key.CURRENT_VERSION))); | |
51 | 51 | } |
52 | 52 | |
53 | 53 | private void initComponents() { |