Code example for BufferedReader

Methods: close, readLine

0
      File cpFile = new File(_rootDirectory, _filePrefix + "current");
      if (cpFile.exists())
      { 
        try 
        { 
          BufferedReader checkpointFile = new BufferedReader(new FileReader(cpFile));
 
          String jsonLine = checkpointFile.readLine();
          if (null == jsonLine)
          { 
            LOG.error("Checkpoint JSON serialization expected");
            hasError = true;
          } 
 
          Checkpoint newCheckpoint = null;
          if (!hasError)
          { 
            try 
            { 
              newCheckpoint = new Checkpoint(jsonLine);
              if (LOG.isDebugEnabled()) LOG.debug("checkpoint loaded:" + newCheckpoint.toString());
            } 
            catch (JsonProcessingException jpe)
            { 
              hasError = true;
              LOG.error("Unable to deserialize checkpoint", jpe);
            } 
          } 
 
          if (!hasError)
          { 
            _checkpoint = newCheckpoint;
          } 
 
          checkpointFile.close();
        } 
        catch (IOException ioe)
        { 
          LOG.error(ioe);
        }