code: public InputStream openKeyStore(String fileName) throws MalformedURLException, IOException {
          InputStream fis = null;
          URL urlFile = null;
          File kfile = null;
  
          try {
              kfile = new File(fileName);
          } catch (NullPointerException e) {
              throw new IOException();
          }
  
          try {
              if (kfile.exists()) {
  
                  // its a file that is there
  
                  if (kfile.length() == 0) {
  
                      // the keystore file is empty
                      // debug
                      throw new IOException(fileName);
                  }
                  // get the url syntax for the fully-qualified filename
                  urlFile = new URL("file:" + kfile.getCanonicalPath());
              } else {
  
                  // otherwise, its a url or a file that doesn't exist
                  try {
                      urlFile = new URL(fileName);
                  } catch (MalformedURLException e) {
  
                      // not proper url syntax
                      // -or- a file that doesn't exist, we don't know which.
  
                      // error message
                      throw e;
                  }
              }
  
          } catch (SecurityException e) {
              // error message
              throw new IOException(fileName);
          }
  
          // Attempt to open the keystore file
  
          try {
              fis = urlFile.openStream();
  
          } catch (IOException e) {
              // error message
              throw e;
          }
  
          return fis;
      }
docs: Open the input filename as a stream.
  
  @param fileName
  @return InputStream
  @throws MalformedURLException
  @throws IOException