Versions Compared

Key

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

...

Code Block
bgColor#FFcccc
class ExceptionExample {
  public static void main(String[] args) throws FileNotFoundException {
    // Linux stores a user's home directory path in the environment variable 
    // $HOME, Windows in %APPDATA%
    FileInputStream fis = new FileInputStream("c:\\"System.getenv("HOME") + args[0]); // Windows
  }
}

Noncompliant Code Example

...

Code Block
bgColor#FFcccc
try {
  FileInputStream fis = new FileInputStream("c:\\"System.getenv("APPDATA") + args[0]);
} catch (FileNotFoundException e) {
  // Log the exception
  throw e;
}

...