Code example for FileReader

Methods: close

0
    LOG.info("Trying to read initial SCN from file: " + _scnFileName);
 
    File file = new File(_scnFileName);
    if (file.exists())
    { 
      FileReader fileReader = new FileReader(file);
      try 
      { 
        BufferedReader reader = new BufferedReader(fileReader);
        String scnLine = reader.readLine();
        if (null != scnLine)
        { 
          try 
          { 
            String scnString = scnLine.substring(0, scnLine.indexOf(SCN_SEPARATOR));
            _scn.set(Long.parseLong(scnString));
 
            LOG.info("Starting from MAX SCN:" + scnString);
          } 
          catch (Exception e)
          { 
            LOG.error("Could not read initial SCN value. Value missing or not in expected format; scnLine = "
                             + scnLine,
                         e);
            throw new DatabusException("Failed to load initial SCN value. Value misisng or not in expected format.", 
                                       e);
          } 
        } 
        else 
        { 
          LOG.warn("SCN file empty; defaulting to initial value from configuration:" +
                      _staticConfig.getInitVal());
          _scn.set(_staticConfig.getInitVal());
        } 
        reader.close();
      } 
      finally 
      { 
        fileReader.close();
      } 
    } 
    else 
    { 
      LOG.info("Initial max SCN does not exist. Defaulting to initial value from configuration: "