gpt4 book ai didi

java - FileReader#mark() 抛出 java.io.IOException

转载 作者:行者123 更新时间:2023-11-30 07:07:32 25 4
gpt4 key购买 nike

这是我的 java 代码的一部分,这段代码在 (A.java:8) 抛出 (java.io.IOException) 请帮忙。

import java.io.FileReader;


public class A {

public A() throws Exception {
FileReader r = new FileReader("a.txt");
r.mark(0);

for(int i=0; i<27; i++)
System.out.println((char)r.read());

r.reset();

for(int i=0; i<27; i++)
System.out.println((char)r.read());

r.close();
}

public static void main(String arg[]) throws Exception {
new A();
}
}

最佳答案

FileReader 不支持mark() 函数

这里是来自grepcode的代码的相关部分:

public void mark(int readAheadLimit) throws IOException {
throw new IOException("mark() not supported");
}

关于java - FileReader#mark() 抛出 java.io.IOException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24862920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com