[英]The method read(File) in the type ImageIO is not applicable for the arguments (String)
So when I replace the urlImage to an actual image path eg "BufferedImage image = ImageIO.read("F:/Java/data/photo.jpg") on the first line of the code it return the following error "The method read(File) in the type ImageIO is not applicable for the arguments (String)" I tried different things but it didn't work, it may sound obvious, I just wasn't able to convert the String type to File.因此,当我将 urlImage 替换为实际图像路径时,例如“BufferedImage image = ImageIO.read("F:/Java/data/photo.jpg") 在代码的第一行它返回以下错误“方法读取( ImageIO 类型中的 File)不适用于参数(String)”我尝试了不同的方法,但没有奏效,这听起来很明显,我只是无法将 String 类型转换为 File。
BufferedImage image = ImageIO.read(urlImage);
int x;
int y;
int c = image.getRGB(x,y);
int red = (c & 0x00ff0000) >> 16;
int green = (c & 0x0000ff00) >> 8;
int blue = c & 0x000000ff;
// and the Java Color is ...
Color color = new Color(red,green,blue);
The method read(File) in the type ImageIO is not applicable for the arguments (String) ImageIO 类型中的方法 read(File) 不适用于参数 (String)
is a pretty clear error.是一个非常明显的错误。 You are passing an String where you need to pass a File.您正在传递一个字符串,您需要传递一个文件。 Just do:做就是了:
BufferedImage image = ImageIO.read(new File(urlImage));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.