product[] readdata(String fn) {
    File ifile = new File(fn);
    FileInputStream f_in = null;
    BufferedInputStream b_in = null;
    DataInputStream d_in = null;
    boolean eof = false;
    product[] pr = new product[50];
    try {
      f_in = new FileInputStream(ifile);
      b_in = new BufferedInputStream(f_in);
      d_in = new DataInputStream(b_in);
      rec = 0;
      while (!eof) {
        pr[rec] = new product();
        pr[rec].id = d_in.readUTF();
        pr[rec].name = d_in.readUTF();
        pr[rec].price = d_in.readFloat();
        rec++;
      }
    }
    catch (EOFException e){
      eof = true;
    }
    catch (FileNotFoundException e){
      return null;
    }
    catch (IOException e){
      return null;
    }
    finally {
      try {
        if (d_in != null)
          d_in.close();
      }
      catch (IOException e){
        System.out.println(e);
      }
    }
    return pr;
  }