title: Using java securityManager blocks me from reading files
body: <p>In my java code I call another 3rd party java class.</p>
  
  <p>I want to catch that latter <code>System.exit()</code> exit code</p>
  
  <p>So I use security-manager as suggested in this <a href="https://stackoverflow.com/questions/5549720/how-to-prevent-calls-to-system-exit-from-terminating-the-jvm">post</a></p>
  
  <p>The problem is that I cannot read files now, I get permissions error</p>
  
  <p>as seen in that <a href="https://stackoverflow.com/questions/44526263/accesscontrolexception-access-denied-for-a-readable-file">post</a>.</p>
  
  <p>How can I catch the exit code and still read files?</p>
  
  <pre><code>Published class MyClass {
  
  class MySecurityManager extends SecurityManager {
      @Override
      public void checkExit(int status) {
          throw new SecurityException();
      }
  }
  
  public void foo() {
      MySecurityManager secManager = new MySecurityManager();
      System.setSecurityManager(secManager);
  
      try {
          ConfigValidator.main(new String[]{"-dirs", SdkServiceConfig.s.PROPERTIES_FILE_PATH});
  
          new FileInputStream(new File("/Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh"));
  
  
      } catch (SecurityException e) {
          //Do something if the external code used System.exit()
          String a = "1";
  
      }
      catch (Exception e) {
  
          logger.error("failed converting properties file to proto", e);
      }
  }
  }
  </code></pre>