[Java] FileInputStream 读取文本内容 →→→→→进入此内容的聊天室

来自 , 2020-10-19, 写在 Java, 查看 105 次.
URL http://www.code666.cn/view/edfbe1af
  1. try {
  2.     fis = new FileInputStream ( "text" );
  3.     System.out.print ( "content of text is : ");
  4.     int b;
  5.     while ( (b = fis.read() ) != -1 ) { //顺序读取文件text里的内容并赋值  给整型变量b, 直到文件结束为止。
  6.         System.out.print ( (char) b );
  7.     }
  8. } catch ( FileNotFoundException e ) {
  9.     System.out.println ( e );
  10. } catch ( IOException e ) {
  11.     System.out.println ( e );
  12. }

回复 "FileInputStream 读取文本内容"

这儿你可以回复上面这条便签

captcha