国产18禁黄网站免费观看,99爱在线精品免费观看,粉嫩metart人体欣赏,99久久99精品久久久久久,6080亚洲人久久精品

2017年計算機二級考試java章節(jié)輔導:例程:顯示一個文件

時間:2017-06-15 15:51:00   來源:無憂考網(wǎng)     [字體: ]

9.6 例程:顯示一個文件

  如果文件的訪問權(quán)限足夠,你可以在TextArea對象里顯示文件內(nèi)容。

  下面是顯示文件的程序片斷:

  FileInputStream fis;

  TextArea ta;

  public vod init(){

  byte b[] = new byte [1024];

  int I; //make it big enough or wait until you //know the size of the file String s;

  try {

  fis = new FileInputStream("/etc/motd");

  }

  catch(FileNotFoundException e) {

  /*do something appropriate */

  }

  try {

  I= fis.read(b);

  }

  catch(IOException e) {

  /* do something appropriate */

  }

  s = new String(b, 0);

  ta = new TextArea(s,5,40); add (ta);

  }