code: public static Object readObject(String fileName, boolean isInternalFile) throws DISIException {
          Object result;
          try {
              InputStream fos = null;
  
              if (isInternalFile == true) {
                  fos = Thread.currentThread().getContextClassLoader().getResource(fileName).openStream();
              } else {
                  fos = new FileInputStream(fileName);
              }
  
              BufferedInputStream bis = new BufferedInputStream(fos);
              ObjectInputStream oos = new ObjectInputStream(bis);
              try {
                  result = oos.readObject();
              } catch (IOException e) {
                  final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
                  log.error(errMessage, e);
                  throw new DISIException(errMessage, e);
              } catch (ClassNotFoundException e) {
                  final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
                  log.error(errMessage, e);
                  throw new DISIException(errMessage, e);
              }
              oos.close();
              bis.close();
              fos.close();
          } catch (IOException e) {
              final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
              log.error(errMessage, e);
              throw new DISIException(errMessage, e);
          }
          return result;
      }
docs: Reads Java object from a file.
  
  @param fileName the file where the object is stored
  @parm isInternalFile reads from internal data file in resources folder
  @return the object
  @throws DISIException DISIException