回答編集履歴
2
cmd\.exeでなくechoを使わない記述にした。
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
`returnString`をkakasiに渡したいのなら、
|
2
2
|
|
3
|
-
c
|
3
|
+
echoはやめて、kakasiを直接実行し、
|
4
4
|
|
5
5
|
`proc.getOutputStream()`した`OutputStream`に`returnString`を書き込んだ方が、
|
6
6
|
|
1
コード例を追記した。
test
CHANGED
@@ -2,6 +2,38 @@
|
|
2
2
|
|
3
3
|
cmd.exeはやめて、kakasiを直接実行し、
|
4
4
|
|
5
|
-
`proc.getOutputStream()`した`OutputStream`にreturnString`書き込んだ方が、
|
5
|
+
`proc.getOutputStream()`した`OutputStream`に`returnString`を書き込んだ方が、
|
6
6
|
|
7
7
|
文字コードをコントロール出来て良いかと思います。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
動作確認出来ていませんが、以下の様なコードになると思います。
|
12
|
+
|
13
|
+
```
|
14
|
+
|
15
|
+
String command = "kakasi -" + cmd + " -i utf-8 -o utf-8";
|
16
|
+
|
17
|
+
-(略)-
|
18
|
+
|
19
|
+
OutputStream os = proc.getOutputStream();
|
20
|
+
|
21
|
+
InputStream is = proc.getInputStream();
|
22
|
+
|
23
|
+
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
|
24
|
+
|
25
|
+
BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
26
|
+
|
27
|
+
String line = null;
|
28
|
+
|
29
|
+
try {
|
30
|
+
|
31
|
+
out.write(returnString);
|
32
|
+
|
33
|
+
out.newLine();
|
34
|
+
|
35
|
+
while ((line = in.readLine()) != null)
|
36
|
+
|
37
|
+
-(略)-
|
38
|
+
|
39
|
+
```
|