Okay, so I have a bunch of questions related to exceptions among SO and Programmers, but there is so much to ask, and either I don’t know what to enter, or not many people asked.
So, let's say I have a method that generates FileNotFoundException(FNFE). Then I have another method that uses the first, but also throws IOException(IOE).
My handler would catch both of them with each, but my IDE (IntelliJ) signals that I have a "more general exception," java.io.IOException, in the list of throws already. "
I know this works if I do this:
public File openOrCreate(String pathStr) throws FileNotFoundException,
IOException {
try {
Path path = ReposioryProposition.getPath(pathStr);
File file = path.toFile();
catch (FileNotFoundException fnfe) {
throw fnfe;
}
if (!file.exists())
file.createNewFile();
return file;
}
? .
, , :
public File openOrCreate(String pathStr) throws FileNotFoundException,
IOException {
Path path = ReposioryProposition.getPath(pathStr);
File file = path.toFile();
if (!file.exists())
file.createNewFile();
return file;
}
, , FNFE, ? , .