简体   繁体   English

ImageIO 类型中的方法 read(File) 不适用于参数 (String)

[英]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.

相关问题 JLabel类型的setText(String)方法不适用于arguments(File) - The method setText(String) in the type JLabel is not applicable for the arguments(File) 类型“ x”的方法search()不适用于参数(字符串) - The method search() in the type “x” is not applicable for the arguments (String) 部分类型中的方法setText(String)不适用于参数 - method setText(String) in the type Part is not applicable for the arguments 类型为nammi的方法epli(String [])不适用于arguments() - The method epli(String[]) in the type nammi is not applicable for the arguments () 类型“x”中的方法 getBytes() 不适用于 arguments(字符串) - The method getBytes() in the type "x" is not applicable for the arguments (String) 类型中的方法不适用于参数 - Method in the type is not applicable to the arguments 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments 类型中的方法不适用于参数 - the method in type not applicable for the arguments 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments JsonObject类型的方法add(String,JsonElement)不适用于参数(String,String) - The method add(String, JsonElement) in the type JsonObject is not applicable for the arguments (String, String)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM