本文整理汇总了Java中java.io.FileNotFoundException.initCause方法的典型用法代码示例。如果您正苦于以下问题:Java FileNotFoundException.initCause方法的具体用法?Java FileNotFoundException.initCause怎么用?Java FileNotFoundException.initCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.FileNotFoundException
的用法示例。
在下文中一共展示了FileNotFoundException.initCause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputStream
import java.io.FileNotFoundException; //导入方法依赖的package包/类
public java.io.InputStream getInputStream () throws java.io.FileNotFoundException {
if (openStreams < 0) {
FileNotFoundException e = new FileNotFoundException("Already exists output stream");
if (previousStream != null) {
e.initCause(previousStream);
}
throw e;
}
class IS extends ByteArrayInputStream {
public IS(byte[] arr) {
super(arr);
openStreams++;
}
@Override
public void close() throws IOException {
openStreams--;
super.close();
}
}
previousStream = new Exception("Input");
return new IS(RUNNING.content.getBytes ());
}
示例2: listChildren
import java.io.FileNotFoundException; //导入方法依赖的package包/类
@Override
public LocalFilesystemURL[] listChildren(LocalFilesystemURL inputURL) throws FileNotFoundException {
String pathNoSlashes = inputURL.path.substring(1);
if (pathNoSlashes.endsWith("/")) {
pathNoSlashes = pathNoSlashes.substring(0, pathNoSlashes.length() - 1);
}
String[] files;
try {
files = listAssets(pathNoSlashes);
} catch (IOException e) {
FileNotFoundException fnfe = new FileNotFoundException();
fnfe.initCause(e);
throw fnfe;
}
LocalFilesystemURL[] entries = new LocalFilesystemURL[files.length];
for (int i = 0; i < files.length; ++i) {
entries[i] = localUrlforFullPath(new File(inputURL.path, files[i]).getPath());
}
return entries;
}
示例3: asFileNotFoundException
import java.io.FileNotFoundException; //导入方法依赖的package包/类
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;
}