谷歌搜索没有任何结果,我想是因为这个错误对Java 8的新糖来说是新的。 当我捕获IOException时,NetBeans为什么告诉我“方法引用中不兼容的抛出类型IOException”?
/**
* Either extracts or returns the pre-extracted language file for the given locale
*
* @param locale the locale
* @return
* @throws IOException
*/
private InputStream getLanguageFile(Locale locale) throws IOException
{
File extracted = SaveConstants.inventSaveFileFor(Main.GAME_NAME, locale.toLanguageTag() + ".lang");
if (!extracted.exists())
{
InputStream in = Resources.getLanguageStream(locale);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
extracted.getParentFile().mkdirs();
try
{
extracted.createNewFile();
Writer writer = new FileWriter(extracted);
reader
.lines()
.forEach(writer::write);
}
catch (IOException ex)
{
Logger.getLogger(Lang.class.getName()).log(Level.SEVERE, "Cannot extract language file for " + locale + ". Loading directly to map", ex);
return in;
}
}
else
return new FileInputStream(extracted);
}
注意:我知道它会因为缺少返回而无法编译,但我希望在继续返回
之前解决这个问题