如何在ISO-8859-15中获取InputStreamReader?

时间:2011-08-21 03:07:52

标签: java character-encoding bufferedreader iso inputstreamreader

如何让此输入流读取ISO-8859-15编码文件?

BufferedReader r = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.jet)));

我发现这条线看起来很有效:

BufferedReader br = new BufferedReader(new InputStreamReader(ftp.getInputStream(), "ISO-8859-15"));

但是

BufferedReader r = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.jet), "ISO-8859-15"));

没有。

1 个答案:

答案 0 :(得分:3)

似乎:

BufferedReader r = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.jet), Charset.forName("ISO-8859-15")));

的工作原理。显然你需要发送一个Charset,而不是一个带有编码的字符串。鉴于此,这似乎很奇怪:

BufferedReader br = new BufferedReader(new InputStreamReader(ftp.getInputStream(), "ISO-8859-15"));