我在使用缓冲读卡器方面遇到了麻烦。我已经知道他们没有给出一个字符串,他们通常会给另一个读者,所以在这里我被指示使用InputStreamReader。我一直得到这个"没有为BufferedWriter(String)"找到合适的构造函数。我的BR中有两个错误,一个用于输入,另一个用于输出。
这就是我所有BR的构建方式:
BufferedReader inStream = new BufferedReader(new InputStreamReader(inFile));
以下是有关错误的其他信息:
BufferedReader inStream = new BufferedReader(new InputStreamReader(inFile));
^
constructor InputStreamReader.InputStreamReader(InputStream,CharsetDecoder) is not applicable
(actual and formal argument lists differ in length)
constructor InputStreamReader.InputStreamReader(InputStream,Charset) is not applicable
(actual and formal argument lists differ in length)
constructor InputStreamReader.InputStreamReader(InputStream,String) is not applicable
(actual and formal argument lists differ in length)
constructor InputStreamReader.InputStreamReader(InputStream) is not applicable
(actual argument String cannot be converted to InputStream by method invocation conversion)
提前致谢。
答案 0 :(得分:1)
如果要将字符串输入到BufferedReader,可以将java.io.StringReader实例传递给构造函数:
BufferedReader br = new BufferedReader(new StringReader("some string"));