有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

字符串Java将文件路径转换为图像

是否有任何方法可以转换此字符串:

D:\Projects\Epic MC mod\fabric-example-mod\run\.\screenshots\2021-06-13_20.24.30.png

如图所示,2021-06-13_20.24.30。巴布亚新几内亚? 就像能跑一样

Image image = D:\Projects\Epic MC mod\fabric-example-mod\run\.\screenshots\2021-06-13_20.24.30.png

结果得到了那张照片


共 (1) 个答案

  1. # 1 楼答案

    您可以使用“javax.imageio.imageio”:

    try {
           Image image = ImageIO.read(new File(filePath));
        } catch (IOException e) {
            e.printStackTrace();
        }