< prev index next >

src/java.base/share/classes/sun/security/action/OpenFileInputStreamAction.java

Print this page
rev 14275 : 8155039: Simplify code to setup SSLContextImpl and TrustManagerFactoryImpl
Reviewed-by: TBD

*** 37,53 **** --- 37,75 ---- public class OpenFileInputStreamAction implements PrivilegedExceptionAction<FileInputStream> { private final File file; + // Return null if the file doesn't exist + private final boolean graceful; + public OpenFileInputStreamAction(File file) { + this(file, false); + } + + public OpenFileInputStreamAction(File file, boolean graceful) { this.file = file; + this.graceful = graceful; } public OpenFileInputStreamAction(String filename) { this.file = new File(filename); + this.graceful = false; } public FileInputStream run() throws Exception { + if (graceful) { + try { + if (file.exists()) { return new FileInputStream(file); + } else { + return null; + } + } catch (FileNotFoundException e) { + // couldn't find it, oh well. + return null; + } + } else { + return new FileInputStream(file); + } } }
< prev index next >