如何写一个图像文件 - Java的ImageIO的

问题描述 投票:0回答:1

我想的图像写入到使用Java ImageIO的文件。这是我的代码:

Document doc = convertDocument (fileName, "grey");                       
      ImageIO.write(Converter.convertSVGToPNG(doc), "png",
              new File(FOLDER_PNG_OUT_GREY + fileName.replaceAll(".svg", ".png")));

但是,我跑我的代码时出现此错误:

java.io.FileNotFoundException:C:\工作\ Eclipse的TDK \ svgManager \ svgManager的\ src \主\资源\图标\ SVG \ grey_png \ $ pac.png(系统找不到指定的路径)

我也尝试:

String pngFileName = FOLDER_PNG_OUT_GREY + fileName.replaceAll(".svg", ".png");
File outputfile = new File(pngFileName);
bImage = ImageIO.read(outputfile);

但后来我得到了错误:无法读取输入文件!

java image spring-boot javax.imageio r.java-file
1个回答
0
投票

我认为,像这样的getResource(String file)方法,让您的图片资源:

File initialImage = new File(YourClass.class.getResource("pac.png").getFile());
© www.soinside.com 2019 - 2024. All rights reserved.