readertest.java

来自「kaffe Java 解释器语言,源码,Java的子集系统,开放源代码」· Java 代码 · 共 53 行

JAVA
53
字号
// ReaderMarkTest.java// submitted by Dalibor Topic <dtopic@socs.uts.edu.au>import java.io.*;public class ReaderTest {	public static void main(String [] args) {		Reader pr = new Reader() {			private int counter = 0;			public void close() throws IOException {			}			public int read(char buf[], int offset, int count)					throws IOException {				if ((counter += count) >= 10000)					throw new IOException("enough");				return count;			}		};		// test mark()		try {			pr.mark(0);		} catch (IOException e) {			System.out.println(e.toString());		}		// test reset()		try {			pr.reset();		}		catch (IOException e) {			System.out.println(e.toString());		}		// test ready()		try {			System.out.println(pr.ready());		} catch (IOException e) {			System.out.println(e.toString());		}		// test skip()		try {			System.out.println(pr.skip(10000));		} catch (IOException e) {			System.out.println(e.toString());		}	}}/* Expected Output:java.io.IOException: mark not supportedjava.io.IOException: reset not supportedfalsejava.io.IOException: enough*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?