Code example for FileReader

Methods: read

0
  /* read port number from a file */ 
  private int readPort(ServerContainer sc) {
    File file = new File(sc.getHttpPortFileName());
    FileReader fr;
    try { 
      fr = new FileReader(file);
    } catch (FileNotFoundException e1) {
      return -1; 
    } 
    char [] cbuf = new char[10];
    int size = 0;
    try { 
      size = fr.read(cbuf);
    } catch (IOException e) {
      return -1; 
    } 
    return Integer.parseInt(new String(cbuf, 0, size));
  } 
   
   
  class MyServerContainer extends ServerContainer