...
| Code Block | ||
|---|---|---|
| ||
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 | ||
|---|---|---|
| ||
try {
FileInputStream fis = new FileInputStream("c:\\"System.getenv("APPDATA") + args[0]);
} catch (FileNotFoundException e) {
// Log the exception
throw e;
}
|
...