Reputation: 41
This is a part of my java code, this code is throwing (java.io.IOException) at (A.java:8) please help.
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();
}
}
Upvotes: 2
Views: 860
Reputation: 4462
FileReader does not support the mark operation.
You can determine this by reading the JavaDoc linked and seeing it doesn't override it or markSupported()
inherited from Reader:
public boolean markSupported()
Tells whether this stream supports the mark() operation.
The default implementation always returns false.
Subclasses should override this method.
Upvotes: 2