Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
public void readSensitiveFile() {
  try {
    SecurityManager sm = System.getSecurityManager();
    if(sm != null) {  // check if file can be read
      sm.checkRead("/temp/tempFile");
    } 
    // access the file
    } 
  } catch (SecurityException se) { /* log exception */ }
}

...

Code Block
bgColor#ccccff
public final void readSensitiveFile() {
  try {
    SecurityManager sm = System.getSecurityManager();
    if(sm != null) {  // check if file can be read
      sm.checkRead("/temp/tempFile");
    } 
    // access the file
    } 
  } catch (SecurityException se) { /* log exception */ }
}

...

Code Block
bgColor#ccccff
private void readSensitiveFile() {
  try {
    SecurityManager sm = System.getSecurityManager();
    if(sm != null) {  // check if file can be read
      sm.checkRead("/temp/tempFile");
    } 
    // access the file
    } 
  } catch (SecurityException se) { /* log exception */ }
}

...