正文

InputStreamReader用法2005-09-16 19:02:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/hurongliang/4832.html

分享到:

//与FileInputStream几乎一样,唯一不同的是他可以读取16为的Unicode字符,如汉字等。import java.io.*; public class InputStreamReaderDemo{ public static void main(String[] args)throws IOException  {  try  {   int b;   InputStreamReader isr = new InputStreamReader (new FileInputStream (new File ("D://testfile//input.log")));   System.out.println ("The content of text is:");   while ((b = isr.read()) != -1)//顺序读取文件text里的内容并赋值给整型变量b,直到文件结束为止。   {    System.out.print((char)b);   }   isr.close();  }  catch(FileNotFoundException e)  {   System.out.println(e);  }  catch(IOException e)  {   System.out.println(e);  }  catch(Exception e)  {   System.out.println(e);  } }}

阅读(17276) | 评论(1)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册