Cannot resolve method 'unread' in 'BufferedReader'
时间: 2023-10-22 13:10:49 浏览: 68
This error occurs because the `BufferedReader` class does not have a method called `unread()`.
If you want to unread a character from a `BufferedReader`, you can use the `mark()` and `reset()` methods. Here's an example:
```
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int c = reader.read(); // read a character
reader.mark(1); // mark the current position
// do something with the character
reader.reset(); // unread the character
```
Alternatively, you can use a `PushbackReader` which provides a `unread()` method:
```
PushbackReader reader = new PushbackReader(new InputStreamReader(System.in));
int c = reader.read(); // read a character
reader.unread(c); // unread the character
```
阅读全文
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)