本文整理了Java中java.io.FileNotFoundException.initCause()
方法的一些代码示例,展示了FileNotFoundException.initCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileNotFoundException.initCause()
方法的具体详情如下:
包路径:java.io.FileNotFoundException
类名称:FileNotFoundException
方法名:initCause
暂无
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
* Create a {@code FileNotFoundException} with the inner nested cause set
* to the given exception. Compensates for the fact that FNFE doesn't
* have an initializer that takes an exception.
* @param text error text
* @param ex inner exception
* @return a new exception to throw.
*/
private static FileNotFoundException fileNotFoundException(String text,
Exception ex) {
return (FileNotFoundException) new FileNotFoundException(text)
.initCause(ex);
}
代码示例来源:origin: pmd/pmd
protected Reader getReader(String sourceFile) throws FileNotFoundException {
try {
return Files.newBufferedReader(new File(sourceFile).toPath(), Charset.defaultCharset());
} catch (IOException e) {
FileNotFoundException ex = new FileNotFoundException(sourceFile);
ex.initCause(e);
throw ex;
}
}
代码示例来源:origin: bumptech/glide
public InputStream open(Uri uri) throws FileNotFoundException {
String path = getPath(uri);
if (TextUtils.isEmpty(path)) {
return null;
}
File file = service.get(path);
if (!isValid(file)) {
return null;
}
Uri thumbnailUri = Uri.fromFile(file);
try {
return contentResolver.openInputStream(thumbnailUri);
// PMD.AvoidCatchingNPE framework method openInputStream can throw NPEs.
} catch (@SuppressWarnings("PMD.AvoidCatchingNPE") NullPointerException e) {
throw (FileNotFoundException)
new FileNotFoundException("NPE opening uri: " + uri + " -> " + thumbnailUri).initCause(e);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
FileNotFoundException fnfe = new FileNotFoundException(name);
if (ex != null) {
fnfe.initCause(ex);
代码示例来源:origin: neo4j/neo4j
format( "File could not be opened [%s]", fileToOpen.getCanonicalPath() ) ).initCause( cause );
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
} catch (IOException e) {
FileNotFoundException fnfe = new FileNotFoundException(root.getAbsolutePath());
fnfe.initCause(e);
throw fnfe;
} catch (RuntimeException e) {
FileNotFoundException fnfe = new FileNotFoundException(root.getAbsolutePath());
fnfe.initCause(e);
throw fnfe;
} finally {
代码示例来源:origin: jooby-project/jooby
@Override
public void render(final View view, final Renderer.Context ctx) throws Exception {
String vname = view.name();
try {
Map<String, Object> locals = ctx.locals();
if (vname.charAt(0) == '/') {
vname = vname.substring(1);
}
PebbleTemplate template = pebble.getTemplate(vname);
Writer writer = new StringWriter();
Map<String, Object> model = new HashMap<>();
// push locals
model.putAll(locals);
model.putIfAbsent("_vname", vname);
// Locale:
Locale locale = (Locale) locals.getOrDefault("locale", ctx.locale());
model.putIfAbsent("locale", locale);
// put model
model.putAll(view.model());
// render and send
template.evaluate(writer, model, locale);
ctx.type(MediaType.html)
.send(writer.toString());
} catch (LoaderException x) {
FileNotFoundException fnf = new FileNotFoundException(x.getMessage().replace("Could not find template", "").trim());
fnf.initCause(x);
throw fnf;
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public AssetFileDescriptor openAssetFile(@NonNull Uri uri, @NonNull String mode)
throws FileNotFoundException {
if (uri.getPath() == null) {
return null;
}
try {
String fileName = getFileName(uri);
boolean pipeMode = uri.getQueryParameter(PARAM_PIPE_MODE) != null;
if (pipeMode) {
ParcelFileDescriptor fileDescriptor = openPipeHelper(uri, null, null, null, this);
return new AssetFileDescriptor(fileDescriptor, 0, C.LENGTH_UNSET);
} else {
return getContext().getAssets().openFd(fileName);
}
} catch (IOException e) {
FileNotFoundException exception = new FileNotFoundException(e.getMessage());
exception.initCause(e);
throw exception;
}
}
代码示例来源:origin: robovm/robovm
ex.initCause(errnoException);
throw ex;
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
e.initCause(parsingError);
throw e;
代码示例来源:origin: metafacture/metafacture-core
private static void throwFileNotFoundException(final String name,
final Throwable t) throws FileNotFoundException {
final FileNotFoundException e = new FileNotFoundException(
"No file, resource or URL found: " + name);
if (t != null) {
e.initCause(t);
}
throw e;
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Create a {@code FileNotFoundException} with the inner nested cause set
* to the given exception. Compensates for the fact that FNFE doesn't
* have an initializer that takes an exception.
* @param text error text
* @param ex inner exception
* @return a new exception to throw.
*/
private static FileNotFoundException fileNotFoundException(String text,
Exception ex) {
return (FileNotFoundException) new FileNotFoundException(text)
.initCause(ex);
}
代码示例来源:origin: gigabytedevelopers/FireFiles
public static FileNotFoundException asFileNotFoundException(Throwable t)
throws FileNotFoundException {
if (t instanceof FileNotFoundException) {
throw (FileNotFoundException) t;
}
final FileNotFoundException fnfe = new FileNotFoundException(t.getMessage());
fnfe.initCause(t);
throw fnfe;
}
代码示例来源:origin: liferay/liferay-ide
public static ZipFile open(File file) throws IOException {
try {
return new ZipFile(file);
}
catch (FileNotFoundException fnfe) {
FileNotFoundException ecxcption = new FileNotFoundException(file.getAbsolutePath());
ecxcption.initCause(fnfe);
throw ecxcption;
}
}
代码示例来源:origin: net.sourceforge.pmd/pmd-core
protected Reader getReader(String sourceFile) throws FileNotFoundException {
try {
return Files.newBufferedReader(new File(sourceFile).toPath(), Charset.defaultCharset());
} catch (IOException e) {
FileNotFoundException ex = new FileNotFoundException(sourceFile);
ex.initCause(e);
throw ex;
}
}
代码示例来源:origin: org.terracotta.toolkit/truezip-repkg
public MemoryMappedReadOnlyFile(File file) throws FileNotFoundException {
channel = new FileInputStream(file).getChannel();
try {
window(0);
} catch (IOException ioe) {
FileNotFoundException fnfe = new FileNotFoundException(ioe.toString());
fnfe.initCause(ioe);
throw fnfe;
}
assert window != null;
assert windowOff == 0;
}
代码示例来源:origin: org.terracotta.agent/truezip-repkg
public MemoryMappedReadOnlyFile(File file) throws FileNotFoundException {
channel = new FileInputStream(file).getChannel();
try {
window(0);
} catch (IOException ioe) {
FileNotFoundException fnfe = new FileNotFoundException(ioe.toString());
fnfe.initCause(ioe);
throw fnfe;
}
assert window != null;
assert windowOff == 0;
}
代码示例来源:origin: org.sonarsource.sonar-plugins.github/github-api
/**
* Deletes this repository.
*/
public void delete() throws IOException {
try {
new Requester(root).method("DELETE").to(getApiTailUrl(""));
} catch (FileNotFoundException x) {
throw (FileNotFoundException) new FileNotFoundException("Failed to delete " + owner.login + "/" + name + "; might not exist, or you might need the delete_repo scope in your token: http://stackoverflow.com/a/19327004/12916").initCause(x);
}
}
代码示例来源:origin: kohsuke/github-api
/**
* Deletes this repository.
*/
public void delete() throws IOException {
try {
new Requester(root).method("DELETE").to(getApiTailUrl(""));
} catch (FileNotFoundException x) {
throw (FileNotFoundException) new FileNotFoundException("Failed to delete " + getOwnerName() + "/" + name + "; might not exist, or you might need the delete_repo scope in your token: http://stackoverflow.com/a/19327004/12916").initCause(x);
}
}
代码示例来源:origin: org.kohsuke/github-api
/**
* Deletes this repository.
*/
public void delete() throws IOException {
try {
new Requester(root).method("DELETE").to(getApiTailUrl(""));
} catch (FileNotFoundException x) {
throw (FileNotFoundException) new FileNotFoundException("Failed to delete " + getOwnerName() + "/" + name + "; might not exist, or you might need the delete_repo scope in your token: http://stackoverflow.com/a/19327004/12916").initCause(x);
}
}
内容来源于网络,如有侵权,请联系作者删除!