Name: tb29552 Date: 09/15/97
Trying to write to a write-protected file yields
a FileNotFound exception. Looking at the source
code, we see that an IOException is being caught
and re-thrown as a FileNotFoundException.
Therefore, we are losing the actual error (file
can't be read) and gaining a bogus error (file can't
be found). Since the original exception is lost,
we don't know (without further work) whether the
file doesn't exist or is just not writable.
excerpting out of FileOutputStream.java <colon>
public FileInputStream(String name) throws FileNotFoundException {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(name);
}
try {
fd = new FileDescriptor();
open(name);
} catch (IOException e) {
throw new FileNotFoundException(name);
}
}
company - Integrated Measurement Systems , email - ###@###.###
======================================================================
Trying to write to a write-protected file yields
a FileNotFound exception. Looking at the source
code, we see that an IOException is being caught
and re-thrown as a FileNotFoundException.
Therefore, we are losing the actual error (file
can't be read) and gaining a bogus error (file can't
be found). Since the original exception is lost,
we don't know (without further work) whether the
file doesn't exist or is just not writable.
excerpting out of FileOutputStream.java <colon>
public FileInputStream(String name) throws FileNotFoundException {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(name);
}
try {
fd = new FileDescriptor();
open(name);
} catch (IOException e) {
throw new FileNotFoundException(name);
}
}
company - Integrated Measurement Systems , email - ###@###.###
======================================================================
- duplicates
-
JDK-4031941 java.io.FileWriter constructor throws incorrect exception
-
- Closed
-
-
JDK-4089850 if file system becomes full during jar extraction get general IOException
-
- Closed
-
-
JDK-4144452 java.io.IOExceptioin: Add Broken pipe subclass
-
- Closed
-
- relates to
-
JDK-4140910 java.io.FileNotFoundException should return more meaningful detail strings
-
- Closed
-
-
JDK-4313886 New I/O: Improved set of I/O exceptions
-
- Closed
-