我有以下代码:
public class Interface {
public void exec(){
try {
_inputStream.read();
BufferedReader br = new BufferedReader( new InputStreamReader( _inputStream ));
System.out.println( br.readLine() );
} catch (IOException e) {
}
}
public void setInputStream( InputStream inputStream ){
_inputStream = inputStream;
}
private InputStream _inputStream;
}
public class Run {
public static void main(String[] args) {
Interface ui = new Interface();
ui.setInputStream( new ByteArrayInputStream( "2 4 N".getBytes( Charset.defaultCharset() ) ) );
ui.exec();
}
}
每当我运行这段代码时,我打印出来的只是
" 4 N"
第一个字符丢失了。我的流发生了什么,我可以做些什么来防止它?