Javax ImageIO IIOException for apparently no reason

前端 未结 2 1215
隐瞒了意图╮
隐瞒了意图╮ 2021-01-26 13:02

Hey all, I have a Java problem. For my senior research class, I\'m pretty much finished but I just have to analyze some data in images I generated. I don\'t want to tag this as

相关标签:
2条回答
  • 2021-01-26 13:26

    In the problematic line, shouldn't it been actualFiles[i] instead of expectedFiles[i]?

    0 讨论(0)
  • 2021-01-26 13:42
    new File("C:\\Users\\Rowe\\workspace\\Senior Research\\testExpect"+expectedFiles[i])
    

    Let's shorten the directory to C:\\yourDir. Your code will be yielding paths like

    C:\\yourDirexpectedFiles1.bmp
    

    Not what you want:

    C:\\yourDir\\expectedFiles1.bmp
    

    You forgot the path separator.

    It is much better to use the two-File-arg constructor to File:

    File actualImageFile = new File(actualDir, expectedFiles[i]);
    actualImage = ImageIO.read(actualImageFile);
    

    Hope that helps!

    0 讨论(0)
提交回复
热议问题