本文整理匯總了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;
}