| 10 | */ |
| 11 | public class InputStreamReaderDemo { |
| 12 | public static void main(String[] args) throws IOException { |
| 13 | // �������� |
| 14 | InputStreamReader isr = new InputStreamReader(new FileInputStream( |
| 15 | "isr.txt")); |
| 16 | |
| 17 | // һ�ζ�ȡһ���ַ� |
| 18 | // int ch = 0; |
| 19 | // while ((ch = isr.read()) != -1) { |
| 20 | // System.out.print((char) ch); |
| 21 | // } |
| 22 | |
| 23 | // һ�ζ�ȡһ���ַ����� |
| 24 | char[] chs = new char[1024]; |
| 25 | int len = 0; |
| 26 | while ((len = isr.read(chs)) != -1) { |
| 27 | System.out.print(new String(chs, 0, len)); |
| 28 | } |
| 29 | |
| 30 | // �ͷ���Դ |
| 31 | isr.close(); |
| 32 | } |
| 33 | } |