0
|
1
|
|
2 package fdl;
|
|
3
|
|
4 import java.io.*;
|
|
5 import java.io.IOException;
|
|
6 import java.nio.*;
|
|
7
|
|
8 public class ByteBufferReader extends Reader {
|
|
9 public ByteBuffer _buf;
|
|
10
|
|
11 public ByteBufferReader(ByteBuffer buf) {
|
|
12 _buf = buf;
|
|
13 _buf.reset();
|
|
14 }
|
|
15
|
|
16 @Override
|
|
17 public int read(char[] cbuf, int off, int len) throws IOException {
|
|
18 // TODO Auto-generated method stub
|
|
19 for(int i=0;i<len;i++) {
|
|
20 cbuf[i]=_buf.getChar();
|
|
21 }
|
|
22 return len;
|
|
23 }
|
|
24
|
|
25 @Override
|
|
26 public void reset() {
|
|
27 _buf.reset();
|
|
28 }
|
|
29
|
|
30 @Override
|
|
31 public void close() throws IOException {
|
|
32 // TODO Auto-generated method stub
|
|
33
|
|
34 }
|
|
35
|
|
36 }
|