【发布时间】:2017-06-28 14:59:34
【问题描述】:
我正在尝试从文件的链接列表中获取文件,然后将获得的图像与 imageView 上的现有图像进行比较,但它给出了空指针异常在此处输入代码
files.stream().map((file) -> file.toPath().toString()).forEachOrdered((string) -> {
try {
Image source =new Image(new FileInputStream(string));
if(source==image){
stringFilePath=string;
}
} catch (FileNotFoundException ex) {
Logger.getLogger(SecondFrameController.class.getName()).log(Level.SEVERE, null, ex);
}
我也用for循环试过了,问题依旧存在
for(File file:files)
{
String string= file.toPath().toString();
try {
Image source =new Image(new FileInputStream(string));
if(source==image){
stringFilePath=string;
}
} catch (FileNotFoundException ex) {
Logger.getLogger(SecondFrameController.class.getName()).log(Level.SEVERE, null, ex);
}
}
【问题讨论】:
标签: java linked-list image-comparison